<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>EasyRTC Documentation</title>
  <script src="scripts/prettify/prettify.js"> </script>
  <script src="scripts/prettify/lang-css.js"> </script>
  <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  <link href="../assets/easyrtc-docs-jsdoc-styles-1.css" media="all" rel="stylesheet" />
</head>
<body>
<header class="template">
	<div class="wrapper-content">
    <a href="../index.html"><img src="../assets/easyrtc-logo.png" alt="EasyRTC Documentation"></a>
		<h1 title="EasyRTC Documentation">Documentation</h1>
	</div>
</header>
<div class="wrapper-docs">
<nav>
	<h2><a href="../index.html">Docs Home</a></h2>
	<h3>EasyRTC Guides</h3>
	<ul>
		<li><a href="../easyrtc_faq.html">FAQ</a></li>
		<li><a href="../easyrtc_gettingStarted.html">Getting Started</a></li>
		<li><a href="../easyrtc_server_install.html">EasyRTC Server: Installation</a></li>
		<li><a href="../easyrtc_client_tutorial.html">EasyRTC Framework Tutorial</a></li>
		<li><a href="../easyrtc_rooms.html">Rooms</a></li>
		<li><a href="../easyrtc_server_configuration.html">EasyRTC Server: Configuration</a></li>
		<li><a href="../easyrtc_server_events.html">EasyRTC Server: Events</a></li>
		<li><a href="../easyrtc_server_ice.html">EasyRTC Server: ICE Configuration</a></li>
		<li><a href="../easyrtc_with_other_servers.html">Using Alongside Other Servers</a></li>
		<li><a href="../easyrtc_server_ssl.html">EasyRTC Server: Using SSL</a></li>
		<li><a href="../easyrtc_webrtc_problems.html">WebRTC Problems and Possible Fixes</a></li>
		<li><a href="../easyrtc_upcoming_features.html">Upcoming Features</a></li>
		<li><a href="../easyrtc_changelog.html">Change Log</a></li>
	</ul>
	<h3>EasyRTC Client Classes</h3>
	<ul>
		<li><a href="../client-api/Easyrtc.html">Easyrtc</a></li>
		<li><a href="../client-api/Easyrtc_App.html">Easyrtc_App</a></li>
		<li><a href="../client-api/Easyrtc_ft.html">Easyrtc_ft</a></li>
		<li><a href="../client-api/Easyrtc_IframeCapture.html">Easyrtc_IframeCapture</a></li>
		<li><a href="../client-api/Easyrtc_No_IframeCapture.html">Easyrtc_No_IframeCapture</a></li>
		<li><a href="../client-api/Easyrtc_Rates.html">Easyrtc_Rates</a></li>
		<li><a href="../client-api/Easyrtc_Recorder.html">Easyrtc_Recorder</a></li>
	</ul>
	<h3>EasyRTC Server Modules</h3>
	<ul>
		<li><a href="../server-api/module-easyrtc_default_event_listeners.html">easyrtc_default_event_listeners</a></li>
		<li><a href="../server-api/module-easyrtc_default_options.html">easyrtc_default_options</a></li>
		<li><a href="../server-api/module-easyrtc_private_obj.html">easyrtc_private_obj</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj.html">easyrtc_public_obj</a></li>
		<li><a href="../server-api/module-easyrtc_util.html">easyrtc_util</a></li>
		<li><a href="../server-api/module-general_util.html">general_util</a></li>
	</ul>
	<h3>EasyRTC Server Classes</h3>
	<ul>
		<li><a href="../server-api/module-easyrtc_default_event_listeners-eventListener.html">eventListener</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj-pub.html">pub</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj-pub.events.html">events</a></li>
		<li><a href="../server-api/module-easyrtc_public_obj-pub.util.html">util</a></li>
		<li><a href="../server-api/module-easyrtc_util-eu.html">eu</a></li>
		<li><a href="../server-api/module-general_util-g.html">g</a></li>
		<li><a href="../server-api/pub.appObj.html">appObj</a></li>
		<li><a href="../server-api/pub.appObj.connectionObj.html">connectionObj</a></li>
		<li><a href="../server-api/pub.appObj.connectionObj.connectionRoomObj.html">connectionRoomObj</a></li>
		<li><a href="../server-api/pub.appObj.roomObj.html">roomObj</a></li>
		<li><a href="../server-api/pub.appObj.sessionObj.html">sessionObj</a></li>
	</ul>
</nav>
<div class="easyrtc-docs-content">
<div id="main">
<h1 class="page-title">Source: easyrtc_int.js</h1>
<section>
<article>
<pre class="prettyprint source linenums easyrtc"><code><a name="line1"></a><div class="linenumber">1</div><div style="width:0em;display:inline-block"></div>/*&nbsp;global&nbsp;define,&nbsp;module,&nbsp;require,&nbsp;console,&nbsp;MediaStreamTrack,&nbsp;createIceServer,&nbsp;RTCIceCandidate,&nbsp;RTCPeerConnection,&nbsp;RTCSessionDescription&nbsp;*/
<a name="line2"></a><div class="linenumber">2</div><div style="width:0em;display:inline-block"></div>/*!
<a name="line3"></a><div class="linenumber">3</div><div style="width:1em;display:inline-block"></div>Script:&nbsp;easyrtc.js
<a name="line4"></a><div class="linenumber">4</div>
<a name="line5"></a><div class="linenumber">5</div><div style="width:2em;display:inline-block"></div>Provides&nbsp;client&nbsp;side&nbsp;support&nbsp;for&nbsp;the&nbsp;EasyRTC&nbsp;framework.
<a name="line6"></a><div class="linenumber">6</div><div style="width:2em;display:inline-block"></div>See&nbsp;the&nbsp;easyrtc_client_api.md&nbsp;and&nbsp;easyrtc_client_tutorial.md
<a name="line7"></a><div class="linenumber">7</div><div style="width:2em;display:inline-block"></div>for&nbsp;more&nbsp;details.
<a name="line8"></a><div class="linenumber">8</div>
<a name="line9"></a><div class="linenumber">9</div><div style="width:1em;display:inline-block"></div>About:&nbsp;License
<a name="line10"></a><div class="linenumber">10</div>
<a name="line11"></a><div class="linenumber">11</div><div style="width:2em;display:inline-block"></div>Copyright&nbsp;(c)&nbsp;2016,&nbsp;Priologic&nbsp;Software&nbsp;Inc.
<a name="line12"></a><div class="linenumber">12</div><div style="width:2em;display:inline-block"></div>All&nbsp;rights&nbsp;reserved.
<a name="line13"></a><div class="linenumber">13</div>
<a name="line14"></a><div class="linenumber">14</div><div style="width:2em;display:inline-block"></div>Redistribution&nbsp;and&nbsp;use&nbsp;in&nbsp;source&nbsp;and&nbsp;binary&nbsp;forms,&nbsp;with&nbsp;or&nbsp;without
<a name="line15"></a><div class="linenumber">15</div><div style="width:2em;display:inline-block"></div>modification,&nbsp;are&nbsp;permitted&nbsp;provided&nbsp;that&nbsp;the&nbsp;following&nbsp;conditions&nbsp;are&nbsp;met:
<a name="line16"></a><div class="linenumber">16</div>
<a name="line17"></a><div class="linenumber">17</div><div style="width:4em;display:inline-block"></div>*&nbsp;Redistributions&nbsp;of&nbsp;source&nbsp;code&nbsp;must&nbsp;retain&nbsp;the&nbsp;above&nbsp;copyright&nbsp;notice,
<a name="line18"></a><div class="linenumber">18</div><div style="width:5em;display:inline-block"></div>this&nbsp;list&nbsp;of&nbsp;conditions&nbsp;and&nbsp;the&nbsp;following&nbsp;disclaimer.
<a name="line19"></a><div class="linenumber">19</div><div style="width:4em;display:inline-block"></div>*&nbsp;Redistributions&nbsp;in&nbsp;binary&nbsp;form&nbsp;must&nbsp;reproduce&nbsp;the&nbsp;above&nbsp;copyright
<a name="line20"></a><div class="linenumber">20</div><div style="width:5em;display:inline-block"></div>notice,&nbsp;this&nbsp;list&nbsp;of&nbsp;conditions&nbsp;and&nbsp;the&nbsp;following&nbsp;disclaimer&nbsp;in&nbsp;the
<a name="line21"></a><div class="linenumber">21</div><div style="width:5em;display:inline-block"></div>documentation&nbsp;and/or&nbsp;other&nbsp;materials&nbsp;provided&nbsp;with&nbsp;the&nbsp;distribution.
<a name="line22"></a><div class="linenumber">22</div>
<a name="line23"></a><div class="linenumber">23</div><div style="width:2em;display:inline-block"></div>THIS&nbsp;SOFTWARE&nbsp;IS&nbsp;PROVIDED&nbsp;BY&nbsp;THE&nbsp;COPYRIGHT&nbsp;HOLDERS&nbsp;AND&nbsp;CONTRIBUTORS&nbsp;"AS&nbsp;IS"
<a name="line24"></a><div class="linenumber">24</div><div style="width:2em;display:inline-block"></div>AND&nbsp;ANY&nbsp;EXPRESS&nbsp;OR&nbsp;IMPLIED&nbsp;WARRANTIES,&nbsp;INCLUDING,&nbsp;BUT&nbsp;NOT&nbsp;LIMITED&nbsp;TO,&nbsp;THE
<a name="line25"></a><div class="linenumber">25</div><div style="width:2em;display:inline-block"></div>IMPLIED&nbsp;WARRANTIES&nbsp;OF&nbsp;MERCHANTABILITY&nbsp;AND&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE
<a name="line26"></a><div class="linenumber">26</div><div style="width:2em;display:inline-block"></div>ARE&nbsp;DISCLAIMED.&nbsp;IN&nbsp;NO&nbsp;EVENT&nbsp;SHALL&nbsp;THE&nbsp;COPYRIGHT&nbsp;HOLDER&nbsp;OR&nbsp;CONTRIBUTORS&nbsp;BE
<a name="line27"></a><div class="linenumber">27</div><div style="width:2em;display:inline-block"></div>LIABLE&nbsp;FOR&nbsp;ANY&nbsp;DIRECT,&nbsp;INDIRECT,&nbsp;INCIDENTAL,&nbsp;SPECIAL,&nbsp;EXEMPLARY,&nbsp;OR
<a name="line28"></a><div class="linenumber">28</div><div style="width:2em;display:inline-block"></div>CONSEQUENTIAL&nbsp;DAMAGES&nbsp;(INCLUDING,&nbsp;BUT&nbsp;NOT&nbsp;LIMITED&nbsp;TO,&nbsp;PROCUREMENT&nbsp;OF
<a name="line29"></a><div class="linenumber">29</div><div style="width:2em;display:inline-block"></div>SUBSTITUTE&nbsp;GOODS&nbsp;OR&nbsp;SERVICES;&nbsp;LOSS&nbsp;OF&nbsp;USE,&nbsp;DATA,&nbsp;OR&nbsp;PROFITS;&nbsp;OR&nbsp;BUSINESS
<a name="line30"></a><div class="linenumber">30</div><div style="width:2em;display:inline-block"></div>INTERRUPTION)&nbsp;HOWEVER&nbsp;CAUSED&nbsp;AND&nbsp;ON&nbsp;ANY&nbsp;THEORY&nbsp;OF&nbsp;LIABILITY,&nbsp;WHETHER&nbsp;IN
<a name="line31"></a><div class="linenumber">31</div><div style="width:2em;display:inline-block"></div>CONTRACT,&nbsp;STRICT&nbsp;LIABILITY,&nbsp;OR&nbsp;TORT&nbsp;(INCLUDING&nbsp;NEGLIGENCE&nbsp;OR&nbsp;OTHERWISE)
<a name="line32"></a><div class="linenumber">32</div><div style="width:2em;display:inline-block"></div>ARISING&nbsp;IN&nbsp;ANY&nbsp;WAY&nbsp;OUT&nbsp;OF&nbsp;THE&nbsp;USE&nbsp;OF&nbsp;THIS&nbsp;SOFTWARE,&nbsp;EVEN&nbsp;IF&nbsp;ADVISED&nbsp;OF&nbsp;THE
<a name="line33"></a><div class="linenumber">33</div><div style="width:2em;display:inline-block"></div>POSSIBILITY&nbsp;OF&nbsp;SUCH&nbsp;DAMAGE.
<a name="line34"></a><div class="linenumber">34</div><div style="width:0em;display:inline-block"></div>*/
<a name="line35"></a><div class="linenumber">35</div>
<a name="line36"></a><div class="linenumber">36</div><div style="width:0em;display:inline-block"></div>(function&nbsp;(root,&nbsp;factory)&nbsp;{
<a name="line37"></a><div class="linenumber">37</div><div style="width:2em;display:inline-block"></div>if&nbsp;(typeof&nbsp;define&nbsp;===&nbsp;'function'&nbsp;&amp;&amp;&nbsp;define.amd)&nbsp;{
<a name="line38"></a><div class="linenumber">38</div><div style="width:4em;display:inline-block"></div>//RequireJS&nbsp;(AMD)&nbsp;build&nbsp;system
<a name="line39"></a><div class="linenumber">39</div><div style="width:4em;display:inline-block"></div>define(['easyrtc_lang',&nbsp;'webrtc-adapter',&nbsp;'socket.io'],&nbsp;factory);
<a name="line40"></a><div class="linenumber">40</div><div style="width:2em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(typeof&nbsp;module&nbsp;===&nbsp;'object'&nbsp;&amp;&amp;&nbsp;module.exports)&nbsp;{
<a name="line41"></a><div class="linenumber">41</div><div style="width:4em;display:inline-block"></div>//CommonJS&nbsp;build&nbsp;system
<a name="line42"></a><div class="linenumber">42</div><div style="width:4em;display:inline-block"></div>module.exports&nbsp;=&nbsp;factory(require('easyrtc_lang'),&nbsp;require('webrtc-adapter'),&nbsp;require('socket.io'));
<a name="line43"></a><div class="linenumber">43</div><div style="width:2em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line44"></a><div class="linenumber">44</div><div style="width:4em;display:inline-block"></div>//Vanilla&nbsp;JS,&nbsp;ensure&nbsp;dependencies&nbsp;are&nbsp;loaded&nbsp;correctly
<a name="line45"></a><div class="linenumber">45</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;window.io&nbsp;===&nbsp;'undefined'&nbsp;||&nbsp;!window.io)&nbsp;{
<a name="line46"></a><div class="linenumber">46</div><div style="width:6em;display:inline-block"></div>throw&nbsp;new&nbsp;Error("easyrtc&nbsp;requires&nbsp;socket.io");
<a name="line47"></a><div class="linenumber">47</div><div style="width:4em;display:inline-block"></div>}
<a name="line48"></a><div class="linenumber">48</div><div style="width:4em;display:inline-block"></div>root.easyrtc&nbsp;=&nbsp;factory(window.easyrtc_lang,&nbsp;window.adapter,&nbsp;window.io);
<a name="line49"></a><div class="linenumber">49</div><div style="width:1em;display:inline-block"></div>}
<a name="line50"></a><div class="linenumber">50</div><div style="width:0em;display:inline-block"></div>}(this,&nbsp;function&nbsp;(easyrtc_lang,&nbsp;adapter,&nbsp;io,&nbsp;undefined)&nbsp;{
<a name="line51"></a><div class="linenumber">51</div>
<a name="line52"></a><div class="linenumber">52</div><div style="width:0em;display:inline-block"></div>"use&nbsp;strict";
<a name="line53"></a><div class="linenumber">53</div><div style="width:0em;display:inline-block"></div>/**
<a name="line54"></a><div class="linenumber">54</div><div style="width:0em;display:inline-block"></div>*&nbsp;@class&nbsp;Easyrtc.
<a name="line55"></a><div class="linenumber">55</div><div style="width:0em;display:inline-block"></div>*
<a name="line56"></a><div class="linenumber">56</div><div style="width:0em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Easyrtc}&nbsp;the&nbsp;new&nbsp;easyrtc&nbsp;instance.
<a name="line57"></a><div class="linenumber">57</div><div style="width:0em;display:inline-block"></div>*
<a name="line58"></a><div class="linenumber">58</div><div style="width:0em;display:inline-block"></div>*&nbsp;@constructs&nbsp;Easyrtc
<a name="line59"></a><div class="linenumber">59</div><div style="width:0em;display:inline-block"></div>*/
<a name="line60"></a><div class="linenumber">60</div><div style="width:0em;display:inline-block"></div>var&nbsp;Easyrtc&nbsp;=&nbsp;function()&nbsp;{
<a name="line61"></a><div class="linenumber">61</div>
<a name="line62"></a><div class="linenumber">62</div><div style="width:2em;display:inline-block"></div>var&nbsp;self&nbsp;=&nbsp;this;
<a name="line63"></a><div class="linenumber">63</div>
<a name="line64"></a><div class="linenumber">64</div><div style="width:2em;display:inline-block"></div>function&nbsp;logDebug&nbsp;(message,&nbsp;obj)&nbsp;{
<a name="line65"></a><div class="linenumber">65</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.debugPrinter)&nbsp;{
<a name="line66"></a><div class="linenumber">66</div><div style="width:6em;display:inline-block"></div>self.debugPrinter(message,&nbsp;obj);
<a name="line67"></a><div class="linenumber">67</div><div style="width:4em;display:inline-block"></div>}
<a name="line68"></a><div class="linenumber">68</div><div style="width:2em;display:inline-block"></div>}
<a name="line69"></a><div class="linenumber">69</div>
<a name="line70"></a><div class="linenumber">70</div><div style="width:2em;display:inline-block"></div>function&nbsp;isEmptyObj(obj)&nbsp;{
<a name="line71"></a><div class="linenumber">71</div><div style="width:4em;display:inline-block"></div>if&nbsp;(obj&nbsp;===&nbsp;null&nbsp;||&nbsp;obj&nbsp;===&nbsp;undefined)&nbsp;{
<a name="line72"></a><div class="linenumber">72</div><div style="width:6em;display:inline-block"></div>return&nbsp;true;
<a name="line73"></a><div class="linenumber">73</div><div style="width:4em;display:inline-block"></div>}
<a name="line74"></a><div class="linenumber">74</div><div style="width:4em;display:inline-block"></div>var&nbsp;key;
<a name="line75"></a><div class="linenumber">75</div><div style="width:4em;display:inline-block"></div>for&nbsp;(key&nbsp;in&nbsp;obj)&nbsp;{
<a name="line76"></a><div class="linenumber">76</div><div style="width:6em;display:inline-block"></div>if&nbsp;(obj.hasOwnProperty(key))&nbsp;{
<a name="line77"></a><div class="linenumber">77</div><div style="width:8em;display:inline-block"></div>return&nbsp;false;
<a name="line78"></a><div class="linenumber">78</div><div style="width:6em;display:inline-block"></div>}
<a name="line79"></a><div class="linenumber">79</div><div style="width:4em;display:inline-block"></div>}
<a name="line80"></a><div class="linenumber">80</div><div style="width:4em;display:inline-block"></div>return&nbsp;true;
<a name="line81"></a><div class="linenumber">81</div><div style="width:2em;display:inline-block"></div>}
<a name="line82"></a><div class="linenumber">82</div>
<a name="line83"></a><div class="linenumber">83</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line84"></a><div class="linenumber">84</div><div style="width:2em;display:inline-block"></div>var&nbsp;autoInitUserMedia&nbsp;=&nbsp;true;
<a name="line85"></a><div class="linenumber">85</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line86"></a><div class="linenumber">86</div><div style="width:2em;display:inline-block"></div>var&nbsp;sdpLocalFilter&nbsp;=&nbsp;null;
<a name="line87"></a><div class="linenumber">87</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line88"></a><div class="linenumber">88</div><div style="width:2em;display:inline-block"></div>var&nbsp;sdpRemoteFilter&nbsp;=&nbsp;null;
<a name="line89"></a><div class="linenumber">89</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line90"></a><div class="linenumber">90</div><div style="width:2em;display:inline-block"></div>var&nbsp;iceCandidateFilter&nbsp;=&nbsp;null;
<a name="line91"></a><div class="linenumber">91</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line92"></a><div class="linenumber">92</div><div style="width:2em;display:inline-block"></div>var&nbsp;iceConnectionStateChangeListener&nbsp;=&nbsp;null;
<a name="line93"></a><div class="linenumber">93</div><div style="width:2em;display:inline-block"></div>var&nbsp;signalingStateChangeListener&nbsp;=&nbsp;null;
<a name="line94"></a><div class="linenumber">94</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line95"></a><div class="linenumber">95</div><div style="width:2em;display:inline-block"></div>var&nbsp;connectionOptions&nbsp;=&nbsp;&nbsp;{
<a name="line96"></a><div class="linenumber">96</div><div style="width:4em;display:inline-block"></div>'connect&nbsp;timeout':&nbsp;10000,
<a name="line97"></a><div class="linenumber">97</div><div style="width:4em;display:inline-block"></div>'force&nbsp;new&nbsp;connection':&nbsp;true
<a name="line98"></a><div class="linenumber">98</div><div style="width:2em;display:inline-block"></div>};
<a name="line99"></a><div class="linenumber">99</div>
<a name="line100"></a><div class="linenumber">100</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line101"></a><div class="linenumber">101</div><div style="width:2em;display:inline-block"></div>//
<a name="line102"></a><div class="linenumber">102</div><div style="width:2em;display:inline-block"></div>//&nbsp;this&nbsp;function&nbsp;replaces&nbsp;the&nbsp;deprecated&nbsp;MediaStream.stop&nbsp;method
<a name="line103"></a><div class="linenumber">103</div><div style="width:2em;display:inline-block"></div>//
<a name="line104"></a><div class="linenumber">104</div><div style="width:2em;display:inline-block"></div>function&nbsp;stopStream(stream)&nbsp;{
<a name="line105"></a><div class="linenumber">105</div><div style="width:3em;display:inline-block"></div>var&nbsp;i;
<a name="line106"></a><div class="linenumber">106</div><div style="width:3em;display:inline-block"></div>var&nbsp;tracks;
<a name="line107"></a><div class="linenumber">107</div>
<a name="line108"></a><div class="linenumber">108</div><div style="width:3em;display:inline-block"></div>tracks&nbsp;=&nbsp;stream.getAudioTracks();
<a name="line109"></a><div class="linenumber">109</div><div style="width:3em;display:inline-block"></div>for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;tracks.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line110"></a><div class="linenumber">110</div><div style="width:5em;display:inline-block"></div>try&nbsp;{
<a name="line111"></a><div class="linenumber">111</div><div style="width:6em;display:inline-block"></div>tracks[i].stop();
<a name="line112"></a><div class="linenumber">112</div><div style="width:5em;display:inline-block"></div>}&nbsp;catch(err){}
<a name="line113"></a><div class="linenumber">113</div><div style="width:3em;display:inline-block"></div>}
<a name="line114"></a><div class="linenumber">114</div><div style="width:3em;display:inline-block"></div>tracks&nbsp;=&nbsp;stream.getVideoTracks();
<a name="line115"></a><div class="linenumber">115</div><div style="width:3em;display:inline-block"></div>for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;tracks.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line116"></a><div class="linenumber">116</div><div style="width:5em;display:inline-block"></div>try&nbsp;{
<a name="line117"></a><div class="linenumber">117</div><div style="width:6em;display:inline-block"></div>tracks[i].stop();
<a name="line118"></a><div class="linenumber">118</div><div style="width:5em;display:inline-block"></div>}&nbsp;catch(err){}
<a name="line119"></a><div class="linenumber">119</div><div style="width:3em;display:inline-block"></div>}
<a name="line120"></a><div class="linenumber">120</div>
<a name="line121"></a><div class="linenumber">121</div><div style="width:3em;display:inline-block"></div>if&nbsp;(typeof&nbsp;stream.stop&nbsp;===&nbsp;'function')&nbsp;{
<a name="line122"></a><div class="linenumber">122</div><div style="width:5em;display:inline-block"></div>try&nbsp;{
<a name="line123"></a><div class="linenumber">123</div><div style="width:6em;display:inline-block"></div>stream.stop();
<a name="line124"></a><div class="linenumber">124</div><div style="width:5em;display:inline-block"></div>}&nbsp;catch(err){}
<a name="line125"></a><div class="linenumber">125</div><div style="width:3em;display:inline-block"></div>}
<a name="line126"></a><div class="linenumber">126</div><div style="width:2em;display:inline-block"></div>}
<a name="line127"></a><div class="linenumber">127</div>
<a name="line128"></a><div class="linenumber">128</div><div style="width:2em;display:inline-block"></div>/**
<a name="line129"></a><div class="linenumber">129</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;functions&nbsp;which&nbsp;filter&nbsp;sdp&nbsp;records&nbsp;before&nbsp;calling&nbsp;setLocalDescription&nbsp;or&nbsp;setRemoteDescription.
<a name="line130"></a><div class="linenumber">130</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;is&nbsp;advanced&nbsp;functionality&nbsp;which&nbsp;can&nbsp;break&nbsp;things,&nbsp;easily.&nbsp;See&nbsp;the&nbsp;easyrtc_rates.js&nbsp;file&nbsp;for&nbsp;a
<a name="line131"></a><div class="linenumber">131</div><div style="width:2em;display:inline-block"></div>*&nbsp;filter&nbsp;builder.
<a name="line132"></a><div class="linenumber">132</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;localFilter&nbsp;a&nbsp;function&nbsp;that&nbsp;takes&nbsp;an&nbsp;sdp&nbsp;string&nbsp;and&nbsp;returns&nbsp;an&nbsp;sdp&nbsp;string.
<a name="line133"></a><div class="linenumber">133</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;remoteFilter&nbsp;a&nbsp;function&nbsp;that&nbsp;takes&nbsp;an&nbsp;sdp&nbsp;string&nbsp;and&nbsp;returns&nbsp;an&nbsp;sdp&nbsp;string.
<a name="line134"></a><div class="linenumber">134</div><div style="width:2em;display:inline-block"></div>*/
<a name="line135"></a><div class="linenumber">135</div><div style="width:2em;display:inline-block"></div>this.setSdpFilters&nbsp;=&nbsp;function(localFilter,&nbsp;remoteFilter)&nbsp;{
<a name="line136"></a><div class="linenumber">136</div><div style="width:4em;display:inline-block"></div>sdpLocalFilter&nbsp;=&nbsp;localFilter;
<a name="line137"></a><div class="linenumber">137</div><div style="width:4em;display:inline-block"></div>sdpRemoteFilter&nbsp;=&nbsp;remoteFilter;
<a name="line138"></a><div class="linenumber">138</div><div style="width:2em;display:inline-block"></div>};
<a name="line139"></a><div class="linenumber">139</div>
<a name="line140"></a><div class="linenumber">140</div><div style="width:2em;display:inline-block"></div>/**
<a name="line141"></a><div class="linenumber">141</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;function&nbsp;to&nbsp;warn&nbsp;about&nbsp;the&nbsp;peer&nbsp;connection&nbsp;closing.
<a name="line142"></a><div class="linenumber">142</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Function}&nbsp;handler:&nbsp;a&nbsp;function&nbsp;that&nbsp;gets&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;an&nbsp;argument.
<a name="line143"></a><div class="linenumber">143</div><div style="width:2em;display:inline-block"></div>*/
<a name="line144"></a><div class="linenumber">144</div><div style="width:2em;display:inline-block"></div>this.setPeerClosedListener&nbsp;=&nbsp;function(&nbsp;handler&nbsp;)&nbsp;{
<a name="line145"></a><div class="linenumber">145</div><div style="width:3em;display:inline-block"></div>this.onPeerClosed&nbsp;=&nbsp;handler;
<a name="line146"></a><div class="linenumber">146</div><div style="width:2em;display:inline-block"></div>};
<a name="line147"></a><div class="linenumber">147</div>
<a name="line148"></a><div class="linenumber">148</div><div style="width:2em;display:inline-block"></div>/**
<a name="line149"></a><div class="linenumber">149</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;function&nbsp;to&nbsp;warn&nbsp;about&nbsp;the&nbsp;peer&nbsp;connection&nbsp;open.
<a name="line150"></a><div class="linenumber">150</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Function}&nbsp;handler:&nbsp;a&nbsp;function&nbsp;that&nbsp;gets&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;an&nbsp;argument.
<a name="line151"></a><div class="linenumber">151</div><div style="width:2em;display:inline-block"></div>*/
<a name="line152"></a><div class="linenumber">152</div><div style="width:2em;display:inline-block"></div>this.setPeerOpenListener&nbsp;=&nbsp;function(&nbsp;handler&nbsp;)&nbsp;{
<a name="line153"></a><div class="linenumber">153</div><div style="width:3em;display:inline-block"></div>this.onPeerOpen&nbsp;=&nbsp;handler;
<a name="line154"></a><div class="linenumber">154</div><div style="width:2em;display:inline-block"></div>};
<a name="line155"></a><div class="linenumber">155</div>
<a name="line156"></a><div class="linenumber">156</div><div style="width:2em;display:inline-block"></div>/**
<a name="line157"></a><div class="linenumber">157</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;function&nbsp;to&nbsp;receive&nbsp;warnings&nbsp;about&nbsp;the&nbsp;peer&nbsp;connection
<a name="line158"></a><div class="linenumber">158</div><div style="width:2em;display:inline-block"></div>*&nbsp;failing.&nbsp;The&nbsp;peer&nbsp;connection&nbsp;may&nbsp;recover&nbsp;by&nbsp;itself.
<a name="line159"></a><div class="linenumber">159</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Function}&nbsp;failingHandler:&nbsp;a&nbsp;function&nbsp;that&nbsp;gets&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;an&nbsp;argument.
<a name="line160"></a><div class="linenumber">160</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Function}&nbsp;recoveredHandler:&nbsp;a&nbsp;function&nbsp;that&nbsp;gets&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;an&nbsp;argument.
<a name="line161"></a><div class="linenumber">161</div><div style="width:2em;display:inline-block"></div>*/
<a name="line162"></a><div class="linenumber">162</div><div style="width:2em;display:inline-block"></div>this.setPeerFailingListener&nbsp;=&nbsp;function(&nbsp;failingHandler,&nbsp;recoveredHandler&nbsp;)&nbsp;{
<a name="line163"></a><div class="linenumber">163</div><div style="width:3em;display:inline-block"></div>this.onPeerFailing&nbsp;=&nbsp;failingHandler;
<a name="line164"></a><div class="linenumber">164</div><div style="width:3em;display:inline-block"></div>this.onPeerRecovered&nbsp;=&nbsp;recoveredHandler;
<a name="line165"></a><div class="linenumber">165</div><div style="width:2em;display:inline-block"></div>};
<a name="line166"></a><div class="linenumber">166</div>
<a name="line167"></a><div class="linenumber">167</div><div style="width:2em;display:inline-block"></div>/**
<a name="line168"></a><div class="linenumber">168</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;function&nbsp;which&nbsp;filters&nbsp;IceCandidate&nbsp;records&nbsp;being&nbsp;sent&nbsp;or&nbsp;received.
<a name="line169"></a><div class="linenumber">169</div><div style="width:2em;display:inline-block"></div>*
<a name="line170"></a><div class="linenumber">170</div><div style="width:2em;display:inline-block"></div>*&nbsp;Candidate&nbsp;records&nbsp;can&nbsp;be&nbsp;received&nbsp;while&nbsp;they&nbsp;are&nbsp;being&nbsp;generated&nbsp;locally&nbsp;(before&nbsp;being
<a name="line171"></a><div class="linenumber">171</div><div style="width:2em;display:inline-block"></div>*&nbsp;sent&nbsp;to&nbsp;a&nbsp;peer),&nbsp;and&nbsp;after&nbsp;they&nbsp;are&nbsp;received&nbsp;by&nbsp;the&nbsp;peer.&nbsp;The&nbsp;filter&nbsp;receives&nbsp;two&nbsp;arguments,&nbsp;the&nbsp;candidate&nbsp;record&nbsp;and&nbsp;a&nbsp;boolean
<a name="line172"></a><div class="linenumber">172</div><div style="width:2em;display:inline-block"></div>*&nbsp;flag&nbsp;that&nbsp;is&nbsp;true&nbsp;for&nbsp;a&nbsp;candidate&nbsp;being&nbsp;received&nbsp;from&nbsp;another&nbsp;peer,
<a name="line173"></a><div class="linenumber">173</div><div style="width:2em;display:inline-block"></div>*&nbsp;and&nbsp;false&nbsp;for&nbsp;a&nbsp;candidate&nbsp;that&nbsp;was&nbsp;generated&nbsp;locally.&nbsp;The&nbsp;candidate&nbsp;record&nbsp;has&nbsp;the&nbsp;form:
<a name="line174"></a><div class="linenumber">174</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;{type:&nbsp;'candidate',&nbsp;label:&nbsp;sdpMLineIndex,&nbsp;id:&nbsp;sdpMid,&nbsp;candidate:&nbsp;candidateString}
<a name="line175"></a><div class="linenumber">175</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;function&nbsp;should&nbsp;return&nbsp;one&nbsp;of&nbsp;the&nbsp;following:&nbsp;the&nbsp;input&nbsp;candidate&nbsp;record,&nbsp;a&nbsp;modified&nbsp;candidate&nbsp;record,&nbsp;or&nbsp;null&nbsp;(indicating&nbsp;that&nbsp;the
<a name="line176"></a><div class="linenumber">176</div><div style="width:2em;display:inline-block"></div>*&nbsp;candidate&nbsp;should&nbsp;be&nbsp;discarded).
<a name="line177"></a><div class="linenumber">177</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;filter
<a name="line178"></a><div class="linenumber">178</div><div style="width:2em;display:inline-block"></div>*/
<a name="line179"></a><div class="linenumber">179</div><div style="width:2em;display:inline-block"></div>this.setIceCandidateFilter&nbsp;=&nbsp;function(filter)&nbsp;{
<a name="line180"></a><div class="linenumber">180</div><div style="width:4em;display:inline-block"></div>iceCandidateFilter&nbsp;=&nbsp;filter;
<a name="line181"></a><div class="linenumber">181</div><div style="width:2em;display:inline-block"></div>};
<a name="line182"></a><div class="linenumber">182</div>
<a name="line183"></a><div class="linenumber">183</div><div style="width:2em;display:inline-block"></div>/**
<a name="line184"></a><div class="linenumber">184</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;function&nbsp;that&nbsp;listens&nbsp;on&nbsp;IceConnectionStateChange&nbsp;events.
<a name="line185"></a><div class="linenumber">185</div><div style="width:2em;display:inline-block"></div>*
<a name="line186"></a><div class="linenumber">186</div><div style="width:2em;display:inline-block"></div>*&nbsp;During&nbsp;ICE&nbsp;negotiation&nbsp;the&nbsp;peer&nbsp;connection&nbsp;fires&nbsp;the&nbsp;iceconnectionstatechange&nbsp;event.
<a name="line187"></a><div class="linenumber">187</div><div style="width:2em;display:inline-block"></div>*&nbsp;It&nbsp;is&nbsp;sometimes&nbsp;useful&nbsp;for&nbsp;the&nbsp;application&nbsp;to&nbsp;learn&nbsp;about&nbsp;these&nbsp;changes,&nbsp;especially&nbsp;if&nbsp;the&nbsp;ICE&nbsp;connection&nbsp;fails.
<a name="line188"></a><div class="linenumber">188</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;function&nbsp;should&nbsp;accept&nbsp;three&nbsp;parameters:&nbsp;the&nbsp;easyrtc&nbsp;id&nbsp;of&nbsp;the&nbsp;peer,&nbsp;the&nbsp;iceconnectionstatechange&nbsp;event&nbsp;target&nbsp;and&nbsp;the&nbsp;iceconnectionstate.
<a name="line189"></a><div class="linenumber">189</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener
<a name="line190"></a><div class="linenumber">190</div><div style="width:2em;display:inline-block"></div>*/
<a name="line191"></a><div class="linenumber">191</div><div style="width:2em;display:inline-block"></div>this.setIceConnectionStateChangeListener&nbsp;=&nbsp;function(listener)&nbsp;{
<a name="line192"></a><div class="linenumber">192</div><div style="width:3em;display:inline-block"></div>iceConnectionStateChangeListener&nbsp;=&nbsp;listener;
<a name="line193"></a><div class="linenumber">193</div><div style="width:2em;display:inline-block"></div>};
<a name="line194"></a><div class="linenumber">194</div>
<a name="line195"></a><div class="linenumber">195</div><div style="width:2em;display:inline-block"></div>/**
<a name="line196"></a><div class="linenumber">196</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;function&nbsp;that&nbsp;listens&nbsp;on&nbsp;SignalingStateChange&nbsp;events.
<a name="line197"></a><div class="linenumber">197</div><div style="width:2em;display:inline-block"></div>*
<a name="line198"></a><div class="linenumber">198</div><div style="width:2em;display:inline-block"></div>*&nbsp;During&nbsp;ICE&nbsp;negotiation&nbsp;the&nbsp;peer&nbsp;connection&nbsp;fires&nbsp;the&nbsp;signalingstatechange&nbsp;event.
<a name="line199"></a><div class="linenumber">199</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;function&nbsp;should&nbsp;accept&nbsp;three&nbsp;parameters:&nbsp;the&nbsp;easyrtc&nbsp;id&nbsp;of&nbsp;the&nbsp;peer,&nbsp;the&nbsp;signalingstatechange&nbsp;event&nbsp;target&nbsp;and&nbsp;the&nbsp;signalingstate.
<a name="line200"></a><div class="linenumber">200</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener
<a name="line201"></a><div class="linenumber">201</div><div style="width:2em;display:inline-block"></div>*/
<a name="line202"></a><div class="linenumber">202</div><div style="width:2em;display:inline-block"></div>this.setSignalingStateChangeListener&nbsp;=&nbsp;function(listener)&nbsp;{
<a name="line203"></a><div class="linenumber">203</div><div style="width:3em;display:inline-block"></div>signalingStateChangeListener&nbsp;=&nbsp;listener;
<a name="line204"></a><div class="linenumber">204</div><div style="width:2em;display:inline-block"></div>};
<a name="line205"></a><div class="linenumber">205</div>
<a name="line206"></a><div class="linenumber">206</div><div style="width:2em;display:inline-block"></div>/**
<a name="line207"></a><div class="linenumber">207</div><div style="width:2em;display:inline-block"></div>*&nbsp;Controls&nbsp;whether&nbsp;a&nbsp;default&nbsp;local&nbsp;media&nbsp;stream&nbsp;should&nbsp;be&nbsp;acquired&nbsp;automatically&nbsp;during&nbsp;calls&nbsp;and&nbsp;accepts
<a name="line208"></a><div class="linenumber">208</div><div style="width:2em;display:inline-block"></div>*&nbsp;if&nbsp;a&nbsp;list&nbsp;of&nbsp;streamNames&nbsp;is&nbsp;not&nbsp;supplied.&nbsp;The&nbsp;default&nbsp;is&nbsp;true,&nbsp;which&nbsp;mimics&nbsp;the&nbsp;behaviour&nbsp;of&nbsp;earlier&nbsp;releases
<a name="line209"></a><div class="linenumber">209</div><div style="width:2em;display:inline-block"></div>*&nbsp;that&nbsp;didn't&nbsp;support&nbsp;multiple&nbsp;streams.&nbsp;This&nbsp;function&nbsp;should&nbsp;be&nbsp;called&nbsp;before&nbsp;easyrtc.call&nbsp;or&nbsp;before&nbsp;entering&nbsp;an
<a name="line210"></a><div class="linenumber">210</div><div style="width:2em;display:inline-block"></div>*&nbsp;accept&nbsp;&nbsp;callback.
<a name="line211"></a><div class="linenumber">211</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;flag&nbsp;true&nbsp;to&nbsp;allocate&nbsp;a&nbsp;default&nbsp;local&nbsp;media&nbsp;stream.
<a name="line212"></a><div class="linenumber">212</div><div style="width:2em;display:inline-block"></div>*/
<a name="line213"></a><div class="linenumber">213</div><div style="width:2em;display:inline-block"></div>this.setAutoInitUserMedia&nbsp;=&nbsp;function(flag)&nbsp;{
<a name="line214"></a><div class="linenumber">214</div><div style="width:4em;display:inline-block"></div>autoInitUserMedia&nbsp;=&nbsp;!!flag;
<a name="line215"></a><div class="linenumber">215</div><div style="width:2em;display:inline-block"></div>};
<a name="line216"></a><div class="linenumber">216</div>
<a name="line217"></a><div class="linenumber">217</div><div style="width:2em;display:inline-block"></div>/**
<a name="line218"></a><div class="linenumber">218</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;performs&nbsp;a&nbsp;printf&nbsp;like&nbsp;formatting.&nbsp;It&nbsp;actually&nbsp;takes&nbsp;an&nbsp;unlimited
<a name="line219"></a><div class="linenumber">219</div><div style="width:2em;display:inline-block"></div>*&nbsp;number&nbsp;of&nbsp;arguments,&nbsp;the&nbsp;declared&nbsp;arguments&nbsp;arg1,&nbsp;arg2,&nbsp;arg3&nbsp;are&nbsp;present&nbsp;just&nbsp;for
<a name="line220"></a><div class="linenumber">220</div><div style="width:2em;display:inline-block"></div>*&nbsp;documentation&nbsp;purposes.
<a name="line221"></a><div class="linenumber">221</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;format&nbsp;A&nbsp;string&nbsp;like&nbsp;"abcd{1}efg{2}hij{1}."
<a name="line222"></a><div class="linenumber">222</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;arg1&nbsp;The&nbsp;value&nbsp;that&nbsp;replaces&nbsp;{1}
<a name="line223"></a><div class="linenumber">223</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;arg2&nbsp;The&nbsp;value&nbsp;that&nbsp;replaces&nbsp;{2}
<a name="line224"></a><div class="linenumber">224</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;arg3&nbsp;The&nbsp;value&nbsp;that&nbsp;replaces&nbsp;{3}
<a name="line225"></a><div class="linenumber">225</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{String}&nbsp;the&nbsp;formatted&nbsp;string.
<a name="line226"></a><div class="linenumber">226</div><div style="width:2em;display:inline-block"></div>*/
<a name="line227"></a><div class="linenumber">227</div><div style="width:2em;display:inline-block"></div>this.format&nbsp;=&nbsp;function(format,&nbsp;arg1,&nbsp;arg2,&nbsp;arg3)&nbsp;{
<a name="line228"></a><div class="linenumber">228</div><div style="width:4em;display:inline-block"></div>var&nbsp;formatted&nbsp;=&nbsp;arguments[0];
<a name="line229"></a><div class="linenumber">229</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;i&nbsp;=&nbsp;1;&nbsp;i&nbsp;&lt;&nbsp;arguments.length;&nbsp;i++)&nbsp;{
<a name="line230"></a><div class="linenumber">230</div><div style="width:6em;display:inline-block"></div>var&nbsp;regexp&nbsp;=&nbsp;new&nbsp;RegExp('\\{'&nbsp;+&nbsp;(i&nbsp;-&nbsp;1)&nbsp;+&nbsp;'\\}',&nbsp;'gi');
<a name="line231"></a><div class="linenumber">231</div><div style="width:6em;display:inline-block"></div>formatted&nbsp;=&nbsp;formatted.replace(regexp,&nbsp;arguments[i]);
<a name="line232"></a><div class="linenumber">232</div><div style="width:4em;display:inline-block"></div>}
<a name="line233"></a><div class="linenumber">233</div><div style="width:4em;display:inline-block"></div>return&nbsp;formatted;
<a name="line234"></a><div class="linenumber">234</div><div style="width:2em;display:inline-block"></div>};
<a name="line235"></a><div class="linenumber">235</div>
<a name="line236"></a><div class="linenumber">236</div><div style="width:2em;display:inline-block"></div>/**
<a name="line237"></a><div class="linenumber">237</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;checks&nbsp;if&nbsp;a&nbsp;socket&nbsp;is&nbsp;actually&nbsp;connected.
<a name="line238"></a><div class="linenumber">238</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line239"></a><div class="linenumber">239</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;socket&nbsp;a&nbsp;socket.io&nbsp;socket.
<a name="line240"></a><div class="linenumber">240</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;true&nbsp;if&nbsp;the&nbsp;socket&nbsp;exists&nbsp;and&nbsp;is&nbsp;connected,&nbsp;false&nbsp;otherwise.
<a name="line241"></a><div class="linenumber">241</div><div style="width:2em;display:inline-block"></div>*/
<a name="line242"></a><div class="linenumber">242</div><div style="width:2em;display:inline-block"></div>function&nbsp;isSocketConnected(socket)&nbsp;{
<a name="line243"></a><div class="linenumber">243</div><div style="width:3em;display:inline-block"></div>return&nbsp;socket&nbsp;&amp;&amp;&nbsp;(
<a name="line244"></a><div class="linenumber">244</div><div style="width:6em;display:inline-block"></div>(socket.socket&nbsp;&amp;&amp;&nbsp;socket.socket.connected)&nbsp;||&nbsp;socket.connected
<a name="line245"></a><div class="linenumber">245</div><div style="width:4em;display:inline-block"></div>);
<a name="line246"></a><div class="linenumber">246</div><div style="width:2em;display:inline-block"></div>}
<a name="line247"></a><div class="linenumber">247</div>
<a name="line248"></a><div class="linenumber">248</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line249"></a><div class="linenumber">249</div><div style="width:2em;display:inline-block"></div>//
<a name="line250"></a><div class="linenumber">250</div><div style="width:2em;display:inline-block"></div>//&nbsp;Maps&nbsp;a&nbsp;key&nbsp;to&nbsp;a&nbsp;language&nbsp;specific&nbsp;string&nbsp;using&nbsp;the&nbsp;easyrtc_lang&nbsp;map.
<a name="line251"></a><div class="linenumber">251</div><div style="width:2em;display:inline-block"></div>//&nbsp;Defaults&nbsp;to&nbsp;the&nbsp;key&nbsp;if&nbsp;the&nbsp;key&nbsp;can&nbsp;not&nbsp;be&nbsp;found,&nbsp;but&nbsp;outputs&nbsp;a&nbsp;warning&nbsp;in&nbsp;that&nbsp;case.
<a name="line252"></a><div class="linenumber">252</div><div style="width:2em;display:inline-block"></div>//&nbsp;This&nbsp;function&nbsp;is&nbsp;only&nbsp;used&nbsp;internally&nbsp;by&nbsp;easyrtc.js
<a name="line253"></a><div class="linenumber">253</div><div style="width:2em;display:inline-block"></div>//
<a name="line254"></a><div class="linenumber">254</div><div style="width:2em;display:inline-block"></div>var&nbsp;haveAudioVideo&nbsp;=&nbsp;{
<a name="line255"></a><div class="linenumber">255</div><div style="width:4em;display:inline-block"></div>audio:&nbsp;false,
<a name="line256"></a><div class="linenumber">256</div><div style="width:4em;display:inline-block"></div>video:&nbsp;false
<a name="line257"></a><div class="linenumber">257</div><div style="width:2em;display:inline-block"></div>};
<a name="line258"></a><div class="linenumber">258</div>
<a name="line259"></a><div class="linenumber">259</div><div style="width:2em;display:inline-block"></div>/**
<a name="line260"></a><div class="linenumber">260</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line261"></a><div class="linenumber">261</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;key
<a name="line262"></a><div class="linenumber">262</div><div style="width:2em;display:inline-block"></div>*/
<a name="line263"></a><div class="linenumber">263</div><div style="width:2em;display:inline-block"></div>this.getConstantString&nbsp;=&nbsp;function(key)&nbsp;{
<a name="line264"></a><div class="linenumber">264</div><div style="width:4em;display:inline-block"></div>if&nbsp;(easyrtc_lang[key])&nbsp;{
<a name="line265"></a><div class="linenumber">265</div><div style="width:6em;display:inline-block"></div>return&nbsp;easyrtc_lang[key];
<a name="line266"></a><div class="linenumber">266</div><div style="width:4em;display:inline-block"></div>}
<a name="line267"></a><div class="linenumber">267</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line268"></a><div class="linenumber">268</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Could&nbsp;not&nbsp;find&nbsp;key='"&nbsp;+&nbsp;key&nbsp;+&nbsp;"'&nbsp;in&nbsp;easyrtc_lang");
<a name="line269"></a><div class="linenumber">269</div><div style="width:6em;display:inline-block"></div>return&nbsp;key;
<a name="line270"></a><div class="linenumber">270</div><div style="width:4em;display:inline-block"></div>}
<a name="line271"></a><div class="linenumber">271</div><div style="width:2em;display:inline-block"></div>};
<a name="line272"></a><div class="linenumber">272</div>
<a name="line273"></a><div class="linenumber">273</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line274"></a><div class="linenumber">274</div><div style="width:2em;display:inline-block"></div>//
<a name="line275"></a><div class="linenumber">275</div><div style="width:2em;display:inline-block"></div>//&nbsp;this&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;events&nbsp;supported&nbsp;by&nbsp;the&nbsp;generalized&nbsp;event&nbsp;listener.
<a name="line276"></a><div class="linenumber">276</div><div style="width:2em;display:inline-block"></div>//
<a name="line277"></a><div class="linenumber">277</div><div style="width:2em;display:inline-block"></div>var&nbsp;allowedEvents&nbsp;=&nbsp;{
<a name="line278"></a><div class="linenumber">278</div><div style="width:4em;display:inline-block"></div>roomOccupant:&nbsp;true,&nbsp;&nbsp;//&nbsp;this&nbsp;receives&nbsp;the&nbsp;list&nbsp;of&nbsp;everybody&nbsp;in&nbsp;any&nbsp;room&nbsp;you&nbsp;belong&nbsp;to
<a name="line279"></a><div class="linenumber">279</div><div style="width:4em;display:inline-block"></div>roomOccupants:&nbsp;true&nbsp;&nbsp;//&nbsp;this&nbsp;receives&nbsp;a&nbsp;{roomName:...,&nbsp;occupants:...}&nbsp;value&nbsp;for&nbsp;a&nbsp;specific&nbsp;room
<a name="line280"></a><div class="linenumber">280</div><div style="width:2em;display:inline-block"></div>};
<a name="line281"></a><div class="linenumber">281</div>
<a name="line282"></a><div class="linenumber">282</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line283"></a><div class="linenumber">283</div><div style="width:2em;display:inline-block"></div>//
<a name="line284"></a><div class="linenumber">284</div><div style="width:2em;display:inline-block"></div>//&nbsp;A&nbsp;map&nbsp;of&nbsp;eventListeners.&nbsp;The&nbsp;key&nbsp;is&nbsp;the&nbsp;event&nbsp;type.
<a name="line285"></a><div class="linenumber">285</div><div style="width:2em;display:inline-block"></div>//
<a name="line286"></a><div class="linenumber">286</div><div style="width:2em;display:inline-block"></div>var&nbsp;eventListeners&nbsp;=&nbsp;{};
<a name="line287"></a><div class="linenumber">287</div>
<a name="line288"></a><div class="linenumber">288</div><div style="width:2em;display:inline-block"></div>/**
<a name="line289"></a><div class="linenumber">289</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;checks&nbsp;if&nbsp;an&nbsp;attempt&nbsp;was&nbsp;made&nbsp;to&nbsp;add&nbsp;an&nbsp;event&nbsp;listener&nbsp;or
<a name="line290"></a><div class="linenumber">290</div><div style="width:2em;display:inline-block"></div>*&nbsp;or&nbsp;emit&nbsp;an&nbsp;unlisted&nbsp;event,&nbsp;since&nbsp;such&nbsp;is&nbsp;typically&nbsp;a&nbsp;typo.
<a name="line291"></a><div class="linenumber">291</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line292"></a><div class="linenumber">292</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;eventName
<a name="line293"></a><div class="linenumber">293</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;callingFunction&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;calling&nbsp;function.
<a name="line294"></a><div class="linenumber">294</div><div style="width:2em;display:inline-block"></div>*/
<a name="line295"></a><div class="linenumber">295</div><div style="width:2em;display:inline-block"></div>function&nbsp;event(eventName,&nbsp;callingFunction)&nbsp;{
<a name="line296"></a><div class="linenumber">296</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;eventName&nbsp;!==&nbsp;'string')&nbsp;{
<a name="line297"></a><div class="linenumber">297</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;callingFunction&nbsp;+&nbsp;"&nbsp;called&nbsp;without&nbsp;a&nbsp;string&nbsp;as&nbsp;the&nbsp;first&nbsp;argument");
<a name="line298"></a><div class="linenumber">298</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"developer&nbsp;error";
<a name="line299"></a><div class="linenumber">299</div><div style="width:4em;display:inline-block"></div>}
<a name="line300"></a><div class="linenumber">300</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!allowedEvents[eventName])&nbsp;{
<a name="line301"></a><div class="linenumber">301</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;callingFunction&nbsp;+&nbsp;"&nbsp;called&nbsp;with&nbsp;a&nbsp;bad&nbsp;event&nbsp;name&nbsp;=&nbsp;"&nbsp;+&nbsp;eventName);
<a name="line302"></a><div class="linenumber">302</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"developer&nbsp;error";
<a name="line303"></a><div class="linenumber">303</div><div style="width:4em;display:inline-block"></div>}
<a name="line304"></a><div class="linenumber">304</div><div style="width:2em;display:inline-block"></div>}
<a name="line305"></a><div class="linenumber">305</div>
<a name="line306"></a><div class="linenumber">306</div><div style="width:2em;display:inline-block"></div>/**
<a name="line307"></a><div class="linenumber">307</div><div style="width:2em;display:inline-block"></div>*&nbsp;Adds&nbsp;an&nbsp;event&nbsp;listener&nbsp;for&nbsp;a&nbsp;particular&nbsp;type&nbsp;of&nbsp;event.
<a name="line308"></a><div class="linenumber">308</div><div style="width:2em;display:inline-block"></div>*&nbsp;Currently&nbsp;the&nbsp;only&nbsp;eventName&nbsp;supported&nbsp;is&nbsp;"roomOccupant".
<a name="line309"></a><div class="linenumber">309</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;eventName&nbsp;the&nbsp;type&nbsp;of&nbsp;the&nbsp;event
<a name="line310"></a><div class="linenumber">310</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;eventListener&nbsp;the&nbsp;function&nbsp;that&nbsp;expects&nbsp;the&nbsp;event.
<a name="line311"></a><div class="linenumber">311</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;eventListener&nbsp;gets&nbsp;called&nbsp;with&nbsp;the&nbsp;eventName&nbsp;as&nbsp;it's&nbsp;first&nbsp;argument,&nbsp;and&nbsp;the&nbsp;event
<a name="line312"></a><div class="linenumber">312</div><div style="width:2em;display:inline-block"></div>*&nbsp;data&nbsp;as&nbsp;it's&nbsp;second&nbsp;argument.
<a name="line313"></a><div class="linenumber">313</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{void}
<a name="line314"></a><div class="linenumber">314</div><div style="width:2em;display:inline-block"></div>*/
<a name="line315"></a><div class="linenumber">315</div><div style="width:2em;display:inline-block"></div>this.addEventListener&nbsp;=&nbsp;function(eventName,&nbsp;eventListener)&nbsp;{
<a name="line316"></a><div class="linenumber">316</div><div style="width:4em;display:inline-block"></div>event(eventName,&nbsp;"addEventListener");
<a name="line317"></a><div class="linenumber">317</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;eventListener&nbsp;!==&nbsp;'function')&nbsp;{
<a name="line318"></a><div class="linenumber">318</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"addEventListener&nbsp;called&nbsp;with&nbsp;a&nbsp;non-function&nbsp;for&nbsp;second&nbsp;argument");
<a name="line319"></a><div class="linenumber">319</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"developer&nbsp;error";
<a name="line320"></a><div class="linenumber">320</div><div style="width:4em;display:inline-block"></div>}
<a name="line321"></a><div class="linenumber">321</div><div style="width:4em;display:inline-block"></div>//
<a name="line322"></a><div class="linenumber">322</div><div style="width:4em;display:inline-block"></div>//&nbsp;remove&nbsp;the&nbsp;event&nbsp;listener&nbsp;if&nbsp;it's&nbsp;already&nbsp;present&nbsp;so&nbsp;we&nbsp;don't&nbsp;end&nbsp;up&nbsp;with&nbsp;two&nbsp;copies
<a name="line323"></a><div class="linenumber">323</div><div style="width:4em;display:inline-block"></div>//
<a name="line324"></a><div class="linenumber">324</div><div style="width:4em;display:inline-block"></div>self.removeEventListener(eventName,&nbsp;eventListener);
<a name="line325"></a><div class="linenumber">325</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!eventListeners[eventName])&nbsp;{
<a name="line326"></a><div class="linenumber">326</div><div style="width:6em;display:inline-block"></div>eventListeners[eventName]&nbsp;=&nbsp;[];
<a name="line327"></a><div class="linenumber">327</div><div style="width:4em;display:inline-block"></div>}
<a name="line328"></a><div class="linenumber">328</div><div style="width:4em;display:inline-block"></div>eventListeners[eventName][eventListeners[eventName].length]&nbsp;=&nbsp;eventListener;
<a name="line329"></a><div class="linenumber">329</div><div style="width:2em;display:inline-block"></div>};
<a name="line330"></a><div class="linenumber">330</div>
<a name="line331"></a><div class="linenumber">331</div><div style="width:2em;display:inline-block"></div>/**
<a name="line332"></a><div class="linenumber">332</div><div style="width:2em;display:inline-block"></div>*&nbsp;Removes&nbsp;an&nbsp;event&nbsp;listener.
<a name="line333"></a><div class="linenumber">333</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;eventName
<a name="line334"></a><div class="linenumber">334</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;eventListener
<a name="line335"></a><div class="linenumber">335</div><div style="width:2em;display:inline-block"></div>*/
<a name="line336"></a><div class="linenumber">336</div><div style="width:2em;display:inline-block"></div>this.removeEventListener&nbsp;=&nbsp;function(eventName,&nbsp;eventListener)&nbsp;{
<a name="line337"></a><div class="linenumber">337</div><div style="width:4em;display:inline-block"></div>event(eventName,&nbsp;"removeEventListener");
<a name="line338"></a><div class="linenumber">338</div><div style="width:4em;display:inline-block"></div>var&nbsp;listeners&nbsp;=&nbsp;eventListeners[eventName];
<a name="line339"></a><div class="linenumber">339</div><div style="width:4em;display:inline-block"></div>var&nbsp;i&nbsp;=&nbsp;0;
<a name="line340"></a><div class="linenumber">340</div><div style="width:4em;display:inline-block"></div>if&nbsp;(listeners)&nbsp;{
<a name="line341"></a><div class="linenumber">341</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;listeners.length;&nbsp;i++)&nbsp;{
<a name="line342"></a><div class="linenumber">342</div><div style="width:8em;display:inline-block"></div>if&nbsp;(listeners[i]&nbsp;===&nbsp;eventListener)&nbsp;{
<a name="line343"></a><div class="linenumber">343</div><div style="width:10em;display:inline-block"></div>if&nbsp;(i&nbsp;&lt;&nbsp;listeners.length&nbsp;-&nbsp;1)&nbsp;{
<a name="line344"></a><div class="linenumber">344</div><div style="width:12em;display:inline-block"></div>listeners[i]&nbsp;=&nbsp;listeners[listeners.length&nbsp;-&nbsp;1];
<a name="line345"></a><div class="linenumber">345</div><div style="width:10em;display:inline-block"></div>}
<a name="line346"></a><div class="linenumber">346</div><div style="width:10em;display:inline-block"></div>listeners.length&nbsp;=&nbsp;listeners.length&nbsp;-&nbsp;1;
<a name="line347"></a><div class="linenumber">347</div><div style="width:8em;display:inline-block"></div>}
<a name="line348"></a><div class="linenumber">348</div><div style="width:6em;display:inline-block"></div>}
<a name="line349"></a><div class="linenumber">349</div><div style="width:4em;display:inline-block"></div>}
<a name="line350"></a><div class="linenumber">350</div><div style="width:2em;display:inline-block"></div>};
<a name="line351"></a><div class="linenumber">351</div>
<a name="line352"></a><div class="linenumber">352</div><div style="width:2em;display:inline-block"></div>/**
<a name="line353"></a><div class="linenumber">353</div><div style="width:2em;display:inline-block"></div>*&nbsp;Emits&nbsp;an&nbsp;event,&nbsp;or&nbsp;in&nbsp;other&nbsp;words,&nbsp;calls&nbsp;all&nbsp;the&nbsp;eventListeners&nbsp;for&nbsp;a
<a name="line354"></a><div class="linenumber">354</div><div style="width:2em;display:inline-block"></div>*&nbsp;particular&nbsp;event.
<a name="line355"></a><div class="linenumber">355</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;eventName
<a name="line356"></a><div class="linenumber">356</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;eventData
<a name="line357"></a><div class="linenumber">357</div><div style="width:2em;display:inline-block"></div>*/
<a name="line358"></a><div class="linenumber">358</div><div style="width:2em;display:inline-block"></div>this.emitEvent&nbsp;=&nbsp;function(eventName,&nbsp;eventData)&nbsp;{
<a name="line359"></a><div class="linenumber">359</div><div style="width:4em;display:inline-block"></div>event(eventName,&nbsp;"emitEvent");
<a name="line360"></a><div class="linenumber">360</div><div style="width:4em;display:inline-block"></div>var&nbsp;listeners&nbsp;=&nbsp;eventListeners[eventName];
<a name="line361"></a><div class="linenumber">361</div><div style="width:4em;display:inline-block"></div>var&nbsp;i&nbsp;=&nbsp;0;
<a name="line362"></a><div class="linenumber">362</div><div style="width:4em;display:inline-block"></div>if&nbsp;(listeners)&nbsp;{
<a name="line363"></a><div class="linenumber">363</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;listeners.length;&nbsp;i++)&nbsp;{
<a name="line364"></a><div class="linenumber">364</div><div style="width:8em;display:inline-block"></div>listeners[i](eventName,&nbsp;eventData);
<a name="line365"></a><div class="linenumber">365</div><div style="width:6em;display:inline-block"></div>}
<a name="line366"></a><div class="linenumber">366</div><div style="width:4em;display:inline-block"></div>}
<a name="line367"></a><div class="linenumber">367</div><div style="width:2em;display:inline-block"></div>};
<a name="line368"></a><div class="linenumber">368</div>
<a name="line369"></a><div class="linenumber">369</div><div style="width:2em;display:inline-block"></div>/**
<a name="line370"></a><div class="linenumber">370</div><div style="width:2em;display:inline-block"></div>*&nbsp;Error&nbsp;codes&nbsp;that&nbsp;the&nbsp;EasyRTC&nbsp;will&nbsp;use&nbsp;in&nbsp;the&nbsp;errorCode&nbsp;field&nbsp;of&nbsp;error&nbsp;object&nbsp;passed
<a name="line371"></a><div class="linenumber">371</div><div style="width:2em;display:inline-block"></div>*&nbsp;to&nbsp;error&nbsp;handler&nbsp;set&nbsp;by&nbsp;easyrtc.setOnError.&nbsp;The&nbsp;error&nbsp;codes&nbsp;are&nbsp;short&nbsp;printable&nbsp;strings.
<a name="line372"></a><div class="linenumber">372</div><div style="width:2em;display:inline-block"></div>*&nbsp;@type&nbsp;Object
<a name="line373"></a><div class="linenumber">373</div><div style="width:2em;display:inline-block"></div>*/
<a name="line374"></a><div class="linenumber">374</div><div style="width:2em;display:inline-block"></div>this.errCodes&nbsp;=&nbsp;{
<a name="line375"></a><div class="linenumber">375</div><div style="width:4em;display:inline-block"></div>BAD_NAME:&nbsp;"BAD_NAME",&nbsp;//&nbsp;a&nbsp;user&nbsp;name&nbsp;wasn't&nbsp;of&nbsp;the&nbsp;desired&nbsp;form
<a name="line376"></a><div class="linenumber">376</div><div style="width:4em;display:inline-block"></div>CALL_ERR:&nbsp;"CALL_ERR",&nbsp;//&nbsp;something&nbsp;went&nbsp;wrong&nbsp;creating&nbsp;the&nbsp;peer&nbsp;connection
<a name="line377"></a><div class="linenumber">377</div><div style="width:4em;display:inline-block"></div>DEVELOPER_ERR:&nbsp;"DEVELOPER_ERR",&nbsp;//&nbsp;the&nbsp;developer&nbsp;using&nbsp;the&nbsp;EasyRTC&nbsp;library&nbsp;made&nbsp;a&nbsp;mistake
<a name="line378"></a><div class="linenumber">378</div><div style="width:4em;display:inline-block"></div>SYSTEM_ERR:&nbsp;"SYSTEM_ERR",&nbsp;//&nbsp;probably&nbsp;an&nbsp;error&nbsp;related&nbsp;to&nbsp;the&nbsp;network
<a name="line379"></a><div class="linenumber">379</div><div style="width:4em;display:inline-block"></div>CONNECT_ERR:&nbsp;"CONNECT_ERR",&nbsp;//&nbsp;error&nbsp;occurred&nbsp;when&nbsp;trying&nbsp;to&nbsp;create&nbsp;a&nbsp;connection
<a name="line380"></a><div class="linenumber">380</div><div style="width:4em;display:inline-block"></div>MEDIA_ERR:&nbsp;"MEDIA_ERR",&nbsp;//&nbsp;unable&nbsp;to&nbsp;get&nbsp;the&nbsp;local&nbsp;media
<a name="line381"></a><div class="linenumber">381</div><div style="width:4em;display:inline-block"></div>MEDIA_WARNING:&nbsp;"MEDIA_WARNING",&nbsp;//&nbsp;didn't&nbsp;get&nbsp;the&nbsp;desired&nbsp;resolution
<a name="line382"></a><div class="linenumber">382</div><div style="width:4em;display:inline-block"></div>INTERNAL_ERR:&nbsp;"INTERNAL_ERR",
<a name="line383"></a><div class="linenumber">383</div><div style="width:4em;display:inline-block"></div>PEER_GONE:&nbsp;"PEER_GONE",&nbsp;//&nbsp;peer&nbsp;doesn't&nbsp;exist
<a name="line384"></a><div class="linenumber">384</div><div style="width:4em;display:inline-block"></div>ALREADY_CONNECTED:&nbsp;"ALREADY_CONNECTED",
<a name="line385"></a><div class="linenumber">385</div><div style="width:4em;display:inline-block"></div>BAD_CREDENTIAL:&nbsp;"BAD_CREDENTIAL",
<a name="line386"></a><div class="linenumber">386</div><div style="width:4em;display:inline-block"></div>ICECANDIDATE_ERR:&nbsp;"ICECANDIDATE_ERR",
<a name="line387"></a><div class="linenumber">387</div><div style="width:4em;display:inline-block"></div>NOVIABLEICE:&nbsp;"NOVIABLEICE",
<a name="line388"></a><div class="linenumber">388</div><div style="width:4em;display:inline-block"></div>SIGNAL_ERR:&nbsp;"SIGNAL_ERR"
<a name="line389"></a><div class="linenumber">389</div><div style="width:2em;display:inline-block"></div>};
<a name="line390"></a><div class="linenumber">390</div>
<a name="line391"></a><div class="linenumber">391</div><div style="width:2em;display:inline-block"></div>this.apiVersion&nbsp;=&nbsp;"1.1.0";
<a name="line392"></a><div class="linenumber">392</div>
<a name="line393"></a><div class="linenumber">393</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Most&nbsp;basic&nbsp;message&nbsp;acknowledgment&nbsp;object&nbsp;*/
<a name="line394"></a><div class="linenumber">394</div><div style="width:2em;display:inline-block"></div>this.ackMessage&nbsp;=&nbsp;{msgType:&nbsp;"ack"};
<a name="line395"></a><div class="linenumber">395</div>
<a name="line396"></a><div class="linenumber">396</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Regular&nbsp;expression&nbsp;pattern&nbsp;for&nbsp;user&nbsp;ids.&nbsp;This&nbsp;will&nbsp;need&nbsp;modification&nbsp;to&nbsp;support&nbsp;non&nbsp;US&nbsp;character&nbsp;sets&nbsp;*/
<a name="line397"></a><div class="linenumber">397</div><div style="width:2em;display:inline-block"></div>this.usernameRegExp&nbsp;=&nbsp;/^(.){1,64}$/;
<a name="line398"></a><div class="linenumber">398</div>
<a name="line399"></a><div class="linenumber">399</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Default&nbsp;cookieId&nbsp;name&nbsp;*/
<a name="line400"></a><div class="linenumber">400</div><div style="width:2em;display:inline-block"></div>this.cookieId&nbsp;=&nbsp;"easyrtcsid";
<a name="line401"></a><div class="linenumber">401</div>
<a name="line402"></a><div class="linenumber">402</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line403"></a><div class="linenumber">403</div><div style="width:2em;display:inline-block"></div>var&nbsp;username&nbsp;=&nbsp;null;
<a name="line404"></a><div class="linenumber">404</div>
<a name="line405"></a><div class="linenumber">405</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Flag&nbsp;to&nbsp;indicate&nbsp;that&nbsp;user&nbsp;is&nbsp;currently&nbsp;logging&nbsp;out&nbsp;*/
<a name="line406"></a><div class="linenumber">406</div><div style="width:2em;display:inline-block"></div>this.loggingOut&nbsp;=&nbsp;false;
<a name="line407"></a><div class="linenumber">407</div>
<a name="line408"></a><div class="linenumber">408</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line409"></a><div class="linenumber">409</div><div style="width:2em;display:inline-block"></div>this.disconnecting&nbsp;=&nbsp;false;
<a name="line410"></a><div class="linenumber">410</div>
<a name="line411"></a><div class="linenumber">411</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line412"></a><div class="linenumber">412</div><div style="width:2em;display:inline-block"></div>//
<a name="line413"></a><div class="linenumber">413</div><div style="width:2em;display:inline-block"></div>//&nbsp;A&nbsp;map&nbsp;of&nbsp;ids&nbsp;to&nbsp;local&nbsp;media&nbsp;streams.
<a name="line414"></a><div class="linenumber">414</div><div style="width:2em;display:inline-block"></div>//
<a name="line415"></a><div class="linenumber">415</div><div style="width:2em;display:inline-block"></div>var&nbsp;namedLocalMediaStreams&nbsp;=&nbsp;{};
<a name="line416"></a><div class="linenumber">416</div>
<a name="line417"></a><div class="linenumber">417</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line418"></a><div class="linenumber">418</div><div style="width:2em;display:inline-block"></div>var&nbsp;sessionFields&nbsp;=&nbsp;[];
<a name="line419"></a><div class="linenumber">419</div>
<a name="line420"></a><div class="linenumber">420</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line421"></a><div class="linenumber">421</div><div style="width:2em;display:inline-block"></div>var&nbsp;receivedMediaConstraints&nbsp;=&nbsp;{};
<a name="line422"></a><div class="linenumber">422</div>
<a name="line423"></a><div class="linenumber">423</div><div style="width:2em;display:inline-block"></div>/**
<a name="line424"></a><div class="linenumber">424</div><div style="width:2em;display:inline-block"></div>*&nbsp;Control&nbsp;whether&nbsp;the&nbsp;client&nbsp;requests&nbsp;audio&nbsp;from&nbsp;a&nbsp;peer&nbsp;during&nbsp;a&nbsp;call.
<a name="line425"></a><div class="linenumber">425</div><div style="width:2em;display:inline-block"></div>*&nbsp;Must&nbsp;be&nbsp;called&nbsp;before&nbsp;the&nbsp;call&nbsp;to&nbsp;have&nbsp;an&nbsp;effect.
<a name="line426"></a><div class="linenumber">426</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;value&nbsp;-&nbsp;true&nbsp;to&nbsp;receive&nbsp;audio,&nbsp;false&nbsp;otherwise.&nbsp;The&nbsp;default&nbsp;is&nbsp;true.
<a name="line427"></a><div class="linenumber">427</div><div style="width:2em;display:inline-block"></div>*/
<a name="line428"></a><div class="linenumber">428</div><div style="width:2em;display:inline-block"></div>this.enableAudioReceive&nbsp;=&nbsp;function(value)&nbsp;{
<a name="line429"></a><div class="linenumber">429</div><div style="width:4em;display:inline-block"></div>if&nbsp;(
<a name="line430"></a><div class="linenumber">430</div><div style="width:6em;display:inline-block"></div>adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line431"></a><div class="linenumber">431</div><div style="width:6em;display:inline-block"></div>(adapter.browserDetails.browser&nbsp;===&nbsp;"firefox"&nbsp;||&nbsp;adapter.browserDetails.browser&nbsp;===&nbsp;"edge")
<a name="line432"></a><div class="linenumber">432</div><div style="width:4em;display:inline-block"></div>)&nbsp;{
<a name="line433"></a><div class="linenumber">433</div><div style="width:6em;display:inline-block"></div>receivedMediaConstraints.offerToReceiveAudio&nbsp;=&nbsp;value;
<a name="line434"></a><div class="linenumber">434</div><div style="width:4em;display:inline-block"></div>}
<a name="line435"></a><div class="linenumber">435</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line436"></a><div class="linenumber">436</div><div style="width:6em;display:inline-block"></div>receivedMediaConstraints.mandatory&nbsp;=&nbsp;receivedMediaConstraints.mandatory&nbsp;||&nbsp;{};
<a name="line437"></a><div class="linenumber">437</div><div style="width:6em;display:inline-block"></div>receivedMediaConstraints.mandatory.OfferToReceiveAudio&nbsp;=&nbsp;value;
<a name="line438"></a><div class="linenumber">438</div><div style="width:4em;display:inline-block"></div>}
<a name="line439"></a><div class="linenumber">439</div><div style="width:2em;display:inline-block"></div>};
<a name="line440"></a><div class="linenumber">440</div>
<a name="line441"></a><div class="linenumber">441</div><div style="width:2em;display:inline-block"></div>/**
<a name="line442"></a><div class="linenumber">442</div><div style="width:2em;display:inline-block"></div>*&nbsp;Control&nbsp;whether&nbsp;the&nbsp;client&nbsp;requests&nbsp;video&nbsp;from&nbsp;a&nbsp;peer&nbsp;during&nbsp;a&nbsp;call.
<a name="line443"></a><div class="linenumber">443</div><div style="width:2em;display:inline-block"></div>*&nbsp;Must&nbsp;be&nbsp;called&nbsp;before&nbsp;the&nbsp;call&nbsp;to&nbsp;have&nbsp;an&nbsp;effect.
<a name="line444"></a><div class="linenumber">444</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;value&nbsp;-&nbsp;true&nbsp;to&nbsp;receive&nbsp;video,&nbsp;false&nbsp;otherwise.&nbsp;The&nbsp;default&nbsp;is&nbsp;true.
<a name="line445"></a><div class="linenumber">445</div><div style="width:2em;display:inline-block"></div>*/
<a name="line446"></a><div class="linenumber">446</div><div style="width:2em;display:inline-block"></div>this.enableVideoReceive&nbsp;=&nbsp;function(value)&nbsp;{
<a name="line447"></a><div class="linenumber">447</div><div style="width:4em;display:inline-block"></div>if&nbsp;(
<a name="line448"></a><div class="linenumber">448</div><div style="width:6em;display:inline-block"></div>adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line449"></a><div class="linenumber">449</div><div style="width:6em;display:inline-block"></div>(adapter.browserDetails.browser&nbsp;===&nbsp;"firefox"&nbsp;||&nbsp;adapter.browserDetails.browser&nbsp;===&nbsp;"edge")
<a name="line450"></a><div class="linenumber">450</div><div style="width:4em;display:inline-block"></div>)&nbsp;{
<a name="line451"></a><div class="linenumber">451</div><div style="width:5em;display:inline-block"></div>receivedMediaConstraints.offerToReceiveVideo&nbsp;=&nbsp;value;
<a name="line452"></a><div class="linenumber">452</div><div style="width:4em;display:inline-block"></div>}
<a name="line453"></a><div class="linenumber">453</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line454"></a><div class="linenumber">454</div><div style="width:6em;display:inline-block"></div>receivedMediaConstraints.mandatory&nbsp;=&nbsp;receivedMediaConstraints.mandatory&nbsp;||&nbsp;{};
<a name="line455"></a><div class="linenumber">455</div><div style="width:6em;display:inline-block"></div>receivedMediaConstraints.mandatory.OfferToReceiveVideo&nbsp;=&nbsp;value;
<a name="line456"></a><div class="linenumber">456</div><div style="width:4em;display:inline-block"></div>}
<a name="line457"></a><div class="linenumber">457</div><div style="width:2em;display:inline-block"></div>};
<a name="line458"></a><div class="linenumber">458</div>
<a name="line459"></a><div class="linenumber">459</div><div style="width:2em;display:inline-block"></div>//&nbsp;True&nbsp;by&nbsp;default
<a name="line460"></a><div class="linenumber">460</div><div style="width:2em;display:inline-block"></div>//&nbsp;TODO&nbsp;should&nbsp;not&nbsp;be&nbsp;true&nbsp;by&nbsp;default&nbsp;only&nbsp;for&nbsp;legacy
<a name="line461"></a><div class="linenumber">461</div><div style="width:2em;display:inline-block"></div>this.enableAudioReceive(true);
<a name="line462"></a><div class="linenumber">462</div><div style="width:2em;display:inline-block"></div>this.enableVideoReceive(true);
<a name="line463"></a><div class="linenumber">463</div>
<a name="line464"></a><div class="linenumber">464</div><div style="width:2em;display:inline-block"></div>function&nbsp;getSourceList(callback,&nbsp;sourceType)&nbsp;{
<a name="line465"></a><div class="linenumber">465</div><div style="width:4em;display:inline-block"></div>navigator.mediaDevices.enumerateDevices().then(
<a name="line466"></a><div class="linenumber">466</div><div style="width:6em;display:inline-block"></div>function(values)&nbsp;{
<a name="line467"></a><div class="linenumber">467</div><div style="width:8em;display:inline-block"></div>var&nbsp;results&nbsp;=&nbsp;[];
<a name="line468"></a><div class="linenumber">468</div><div style="width:8em;display:inline-block"></div>for&nbsp;(var&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;values.length;&nbsp;i++)&nbsp;{
<a name="line469"></a><div class="linenumber">469</div><div style="width:10em;display:inline-block"></div>var&nbsp;source&nbsp;=&nbsp;values[i];
<a name="line470"></a><div class="linenumber">470</div><div style="width:10em;display:inline-block"></div>if&nbsp;(source.kind&nbsp;===&nbsp;sourceType)&nbsp;{
<a name="line471"></a><div class="linenumber">471</div><div style="width:12em;display:inline-block"></div>source.id&nbsp;=&nbsp;source.deviceId;&nbsp;//backwards&nbsp;compatibility
<a name="line472"></a><div class="linenumber">472</div><div style="width:12em;display:inline-block"></div>results.push(source);
<a name="line473"></a><div class="linenumber">473</div><div style="width:10em;display:inline-block"></div>}
<a name="line474"></a><div class="linenumber">474</div><div style="width:8em;display:inline-block"></div>}
<a name="line475"></a><div class="linenumber">475</div><div style="width:8em;display:inline-block"></div>callback(results);
<a name="line476"></a><div class="linenumber">476</div><div style="width:6em;display:inline-block"></div>}
<a name="line477"></a><div class="linenumber">477</div><div style="width:5em;display:inline-block"></div>).catch(
<a name="line478"></a><div class="linenumber">478</div><div style="width:6em;display:inline-block"></div>function(reason)&nbsp;{
<a name="line479"></a><div class="linenumber">479</div><div style="width:7em;display:inline-block"></div>logDebug("Unable&nbsp;to&nbsp;enumerate&nbsp;devices&nbsp;("&nbsp;+&nbsp;reason&nbsp;+&nbsp;")");
<a name="line480"></a><div class="linenumber">480</div><div style="width:6em;display:inline-block"></div>}
<a name="line481"></a><div class="linenumber">481</div><div style="width:4em;display:inline-block"></div>);
<a name="line482"></a><div class="linenumber">482</div><div style="width:2em;display:inline-block"></div>}
<a name="line483"></a><div class="linenumber">483</div>
<a name="line484"></a><div class="linenumber">484</div><div style="width:2em;display:inline-block"></div>/**
<a name="line485"></a><div class="linenumber">485</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;audio&nbsp;output&nbsp;device&nbsp;of&nbsp;a&nbsp;Video&nbsp;object.&nbsp;
<a name="line486"></a><div class="linenumber">486</div><div style="width:2em;display:inline-block"></div>*&nbsp;That&nbsp;is&nbsp;to&nbsp;say,&nbsp;this&nbsp;controls&nbsp;what&nbsp;speakers&nbsp;get&nbsp;the&nbsp;sound.
<a name="line487"></a><div class="linenumber">487</div><div style="width:2em;display:inline-block"></div>*&nbsp;In&nbsp;theory,&nbsp;this&nbsp;works&nbsp;on&nbsp;Chrome&nbsp;but&nbsp;probably&nbsp;doesn't&nbsp;work&nbsp;anywhere&nbsp;else&nbsp;yet.
<a name="line488"></a><div class="linenumber">488</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;code&nbsp;was&nbsp;cribbed&nbsp;from&nbsp;https://webrtc.github.io/samples/src/content/devices/multi/.
<a name="line489"></a><div class="linenumber">489</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Object}&nbsp;element&nbsp;an&nbsp;HTML5&nbsp;video&nbsp;element
<a name="line490"></a><div class="linenumber">490</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{String}&nbsp;sinkId&nbsp;a&nbsp;deviceid&nbsp;from&nbsp;getAudioSinkList
<a name="line491"></a><div class="linenumber">491</div><div style="width:2em;display:inline-block"></div>*/
<a name="line492"></a><div class="linenumber">492</div><div style="width:2em;display:inline-block"></div>this.setAudioOutput&nbsp;=&nbsp;function(element,&nbsp;sinkId)&nbsp;{
<a name="line493"></a><div class="linenumber">493</div><div style="width:3em;display:inline-block"></div>if&nbsp;(typeof&nbsp;element.sinkId&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line494"></a><div class="linenumber">494</div><div style="width:5em;display:inline-block"></div>element.setSinkId(sinkId)
<a name="line495"></a><div class="linenumber">495</div><div style="width:5em;display:inline-block"></div>.then(function()&nbsp;{
<a name="line496"></a><div class="linenumber">496</div><div style="width:6em;display:inline-block"></div>logDebug('Success,&nbsp;audio&nbsp;output&nbsp;device&nbsp;attached:&nbsp;'&nbsp;+&nbsp;sinkId&nbsp;+&nbsp;'&nbsp;to&nbsp;'&nbsp;+
<a name="line497"></a><div class="linenumber">497</div><div style="width:8em;display:inline-block"></div>'element&nbsp;with&nbsp;'&nbsp;+&nbsp;element.title&nbsp;+&nbsp;'&nbsp;as&nbsp;source.');
<a name="line498"></a><div class="linenumber">498</div><div style="width:5em;display:inline-block"></div>})
<a name="line499"></a><div class="linenumber">499</div><div style="width:5em;display:inline-block"></div>.catch(function(error)&nbsp;{
<a name="line500"></a><div class="linenumber">500</div><div style="width:6em;display:inline-block"></div>var&nbsp;errorMessage&nbsp;=&nbsp;error;
<a name="line501"></a><div class="linenumber">501</div><div style="width:6em;display:inline-block"></div>if&nbsp;(error.name&nbsp;===&nbsp;'SecurityError')&nbsp;{
<a name="line502"></a><div class="linenumber">502</div><div style="width:7em;display:inline-block"></div>errorMessage&nbsp;=&nbsp;'You&nbsp;need&nbsp;to&nbsp;use&nbsp;HTTPS&nbsp;for&nbsp;selecting&nbsp;audio&nbsp;output&nbsp;'&nbsp;+
<a name="line503"></a><div class="linenumber">503</div><div style="width:9em;display:inline-block"></div>'device:&nbsp;'&nbsp;+&nbsp;error;
<a name="line504"></a><div class="linenumber">504</div><div style="width:6em;display:inline-block"></div>}
<a name="line505"></a><div class="linenumber">505</div><div style="width:6em;display:inline-block"></div>logDebug(errorMessage);
<a name="line506"></a><div class="linenumber">506</div><div style="width:5em;display:inline-block"></div>});
<a name="line507"></a><div class="linenumber">507</div><div style="width:3em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line508"></a><div class="linenumber">508</div><div style="width:5em;display:inline-block"></div>logDebug('Browser&nbsp;does&nbsp;not&nbsp;support&nbsp;output&nbsp;device&nbsp;selection.');
<a name="line509"></a><div class="linenumber">509</div><div style="width:3em;display:inline-block"></div>}
<a name="line510"></a><div class="linenumber">510</div><div style="width:2em;display:inline-block"></div>};
<a name="line511"></a><div class="linenumber">511</div>
<a name="line512"></a><div class="linenumber">512</div><div style="width:2em;display:inline-block"></div>/**
<a name="line513"></a><div class="linenumber">513</div><div style="width:2em;display:inline-block"></div>*&nbsp;Gets&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;available&nbsp;audio&nbsp;sinks&nbsp;(ie,&nbsp;speakers)
<a name="line514"></a><div class="linenumber">514</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callback&nbsp;receives&nbsp;list&nbsp;of&nbsp;{deviceId:String,&nbsp;groupId:String,&nbsp;label:String,&nbsp;kind:"audio"}
<a name="line515"></a><div class="linenumber">515</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example&nbsp;&nbsp;easyrtc.getAudioSinkList(&nbsp;function(list)&nbsp;{
<a name="line516"></a><div class="linenumber">516</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;i;
<a name="line517"></a><div class="linenumber">517</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;list.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line518"></a><div class="linenumber">518</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("label="&nbsp;+&nbsp;list[i].label&nbsp;+&nbsp;",&nbsp;id=&nbsp;"&nbsp;+&nbsp;list[i].deviceId);
<a name="line519"></a><div class="linenumber">519</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line520"></a><div class="linenumber">520</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line521"></a><div class="linenumber">521</div><div style="width:2em;display:inline-block"></div>*/
<a name="line522"></a><div class="linenumber">522</div><div style="width:2em;display:inline-block"></div>this.getAudioSinkList&nbsp;=&nbsp;function(callback){
<a name="line523"></a><div class="linenumber">523</div><div style="width:3em;display:inline-block"></div>getSourceList(callback,&nbsp;"audiooutput");
<a name="line524"></a><div class="linenumber">524</div><div style="width:2em;display:inline-block"></div>};
<a name="line525"></a><div class="linenumber">525</div><div style="width:2em;display:inline-block"></div>/**
<a name="line526"></a><div class="linenumber">526</div><div style="width:2em;display:inline-block"></div>*&nbsp;Gets&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;available&nbsp;audio&nbsp;sources&nbsp;(ie,&nbsp;microphones)
<a name="line527"></a><div class="linenumber">527</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callback&nbsp;receives&nbsp;list&nbsp;of&nbsp;{deviceId:String,&nbsp;groupId:String,&nbsp;label:String,&nbsp;kind:"audio"}
<a name="line528"></a><div class="linenumber">528</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example&nbsp;&nbsp;easyrtc.getAudioSourceList(&nbsp;function(list)&nbsp;{
<a name="line529"></a><div class="linenumber">529</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;i;
<a name="line530"></a><div class="linenumber">530</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;list.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line531"></a><div class="linenumber">531</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("label="&nbsp;+&nbsp;list[i].label&nbsp;+&nbsp;",&nbsp;id=&nbsp;"&nbsp;+&nbsp;list[i].deviceId);
<a name="line532"></a><div class="linenumber">532</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line533"></a><div class="linenumber">533</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line534"></a><div class="linenumber">534</div><div style="width:2em;display:inline-block"></div>*/
<a name="line535"></a><div class="linenumber">535</div><div style="width:2em;display:inline-block"></div>this.getAudioSourceList&nbsp;=&nbsp;function(callback){
<a name="line536"></a><div class="linenumber">536</div><div style="width:3em;display:inline-block"></div>getSourceList(callback,&nbsp;"audioinput");
<a name="line537"></a><div class="linenumber">537</div><div style="width:2em;display:inline-block"></div>};
<a name="line538"></a><div class="linenumber">538</div>
<a name="line539"></a><div class="linenumber">539</div><div style="width:2em;display:inline-block"></div>/**
<a name="line540"></a><div class="linenumber">540</div><div style="width:2em;display:inline-block"></div>*&nbsp;Gets&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;available&nbsp;video&nbsp;sources&nbsp;(ie,&nbsp;cameras)
<a name="line541"></a><div class="linenumber">541</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callback&nbsp;receives&nbsp;list&nbsp;of&nbsp;{deviceId:String,&nbsp;groupId:String,&nbsp;label:String,&nbsp;kind:"video"}
<a name="line542"></a><div class="linenumber">542</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example&nbsp;&nbsp;easyrtc.getVideoSourceList(&nbsp;function(list)&nbsp;{
<a name="line543"></a><div class="linenumber">543</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;i;
<a name="line544"></a><div class="linenumber">544</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;list.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line545"></a><div class="linenumber">545</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("label="&nbsp;+&nbsp;list[i].label&nbsp;+&nbsp;",&nbsp;id=&nbsp;"&nbsp;+&nbsp;list[i].deviceId);
<a name="line546"></a><div class="linenumber">546</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line547"></a><div class="linenumber">547</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line548"></a><div class="linenumber">548</div><div style="width:2em;display:inline-block"></div>*/
<a name="line549"></a><div class="linenumber">549</div><div style="width:2em;display:inline-block"></div>this.getVideoSourceList&nbsp;=&nbsp;function(callback)&nbsp;{
<a name="line550"></a><div class="linenumber">550</div><div style="width:3em;display:inline-block"></div>getSourceList(callback,&nbsp;"videoinput");
<a name="line551"></a><div class="linenumber">551</div><div style="width:2em;display:inline-block"></div>};
<a name="line552"></a><div class="linenumber">552</div>
<a name="line553"></a><div class="linenumber">553</div>
<a name="line554"></a><div class="linenumber">554</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line555"></a><div class="linenumber">555</div><div style="width:2em;display:inline-block"></div>var&nbsp;dataChannelName&nbsp;=&nbsp;"dc";
<a name="line556"></a><div class="linenumber">556</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line557"></a><div class="linenumber">557</div><div style="width:2em;display:inline-block"></div>var&nbsp;oldConfig&nbsp;=&nbsp;{};
<a name="line558"></a><div class="linenumber">558</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line559"></a><div class="linenumber">559</div><div style="width:2em;display:inline-block"></div>var&nbsp;offersPending&nbsp;=&nbsp;{};
<a name="line560"></a><div class="linenumber">560</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line561"></a><div class="linenumber">561</div><div style="width:2em;display:inline-block"></div>var&nbsp;credential&nbsp;=&nbsp;null;
<a name="line562"></a><div class="linenumber">562</div>
<a name="line563"></a><div class="linenumber">563</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line564"></a><div class="linenumber">564</div><div style="width:2em;display:inline-block"></div>self.audioEnabled&nbsp;=&nbsp;true;
<a name="line565"></a><div class="linenumber">565</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line566"></a><div class="linenumber">566</div><div style="width:2em;display:inline-block"></div>self.videoEnabled&nbsp;=&nbsp;true;
<a name="line567"></a><div class="linenumber">567</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line568"></a><div class="linenumber">568</div><div style="width:2em;display:inline-block"></div>this.debugPrinter&nbsp;=&nbsp;null;
<a name="line569"></a><div class="linenumber">569</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Your&nbsp;easyrtcid&nbsp;*/
<a name="line570"></a><div class="linenumber">570</div><div style="width:2em;display:inline-block"></div>this.myEasyrtcid&nbsp;=&nbsp;"";
<a name="line571"></a><div class="linenumber">571</div>
<a name="line572"></a><div class="linenumber">572</div><div style="width:2em;display:inline-block"></div>/**&nbsp;The&nbsp;height&nbsp;of&nbsp;the&nbsp;local&nbsp;media&nbsp;stream&nbsp;video&nbsp;in&nbsp;pixels.&nbsp;This&nbsp;field&nbsp;is&nbsp;set&nbsp;an&nbsp;indeterminate&nbsp;period
<a name="line573"></a><div class="linenumber">573</div><div style="width:2em;display:inline-block"></div>*&nbsp;of&nbsp;time&nbsp;after&nbsp;easyrtc.initMediaSource&nbsp;succeeds.&nbsp;Note:&nbsp;in&nbsp;actuality,&nbsp;the&nbsp;dimensions&nbsp;of&nbsp;a&nbsp;video&nbsp;stream
<a name="line574"></a><div class="linenumber">574</div><div style="width:2em;display:inline-block"></div>*&nbsp;change&nbsp;dynamically&nbsp;in&nbsp;response&nbsp;to&nbsp;external&nbsp;factors,&nbsp;you&nbsp;should&nbsp;check&nbsp;the&nbsp;videoWidth&nbsp;and&nbsp;videoHeight&nbsp;attributes
<a name="line575"></a><div class="linenumber">575</div><div style="width:2em;display:inline-block"></div>*&nbsp;of&nbsp;your&nbsp;video&nbsp;objects&nbsp;before&nbsp;you&nbsp;use&nbsp;them&nbsp;for&nbsp;pixel&nbsp;specific&nbsp;operations.
<a name="line576"></a><div class="linenumber">576</div><div style="width:2em;display:inline-block"></div>*/
<a name="line577"></a><div class="linenumber">577</div><div style="width:2em;display:inline-block"></div>this.nativeVideoHeight&nbsp;=&nbsp;0;
<a name="line578"></a><div class="linenumber">578</div>
<a name="line579"></a><div class="linenumber">579</div><div style="width:2em;display:inline-block"></div>/**&nbsp;This&nbsp;constant&nbsp;determines&nbsp;how&nbsp;long&nbsp;(in&nbsp;bytes)&nbsp;a&nbsp;message&nbsp;can&nbsp;be&nbsp;before&nbsp;being&nbsp;split&nbsp;in&nbsp;chunks&nbsp;of&nbsp;that&nbsp;size.
<a name="line580"></a><div class="linenumber">580</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;is&nbsp;because&nbsp;there&nbsp;is&nbsp;a&nbsp;limitation&nbsp;of&nbsp;the&nbsp;length&nbsp;of&nbsp;the&nbsp;message&nbsp;you&nbsp;can&nbsp;send&nbsp;on&nbsp;the
<a name="line581"></a><div class="linenumber">581</div><div style="width:2em;display:inline-block"></div>*&nbsp;data&nbsp;channel&nbsp;between&nbsp;browsers.
<a name="line582"></a><div class="linenumber">582</div><div style="width:2em;display:inline-block"></div>*/
<a name="line583"></a><div class="linenumber">583</div><div style="width:2em;display:inline-block"></div>this.maxP2PMessageLength&nbsp;=&nbsp;1000;
<a name="line584"></a><div class="linenumber">584</div>
<a name="line585"></a><div class="linenumber">585</div><div style="width:2em;display:inline-block"></div>/**&nbsp;The&nbsp;width&nbsp;of&nbsp;the&nbsp;local&nbsp;media&nbsp;stream&nbsp;video&nbsp;in&nbsp;pixels.&nbsp;This&nbsp;field&nbsp;is&nbsp;set&nbsp;an&nbsp;indeterminate&nbsp;period
<a name="line586"></a><div class="linenumber">586</div><div style="width:2em;display:inline-block"></div>*&nbsp;of&nbsp;time&nbsp;after&nbsp;easyrtc.initMediaSource&nbsp;succeeds.&nbsp;&nbsp;Note:&nbsp;in&nbsp;actuality,&nbsp;the&nbsp;dimensions&nbsp;of&nbsp;a&nbsp;video&nbsp;stream
<a name="line587"></a><div class="linenumber">587</div><div style="width:2em;display:inline-block"></div>*&nbsp;change&nbsp;dynamically&nbsp;in&nbsp;response&nbsp;to&nbsp;external&nbsp;factors,&nbsp;you&nbsp;should&nbsp;check&nbsp;the&nbsp;videoWidth&nbsp;and&nbsp;videoHeight&nbsp;attributes
<a name="line588"></a><div class="linenumber">588</div><div style="width:2em;display:inline-block"></div>*&nbsp;of&nbsp;your&nbsp;video&nbsp;objects&nbsp;before&nbsp;you&nbsp;use&nbsp;them&nbsp;for&nbsp;pixel&nbsp;specific&nbsp;operations.
<a name="line589"></a><div class="linenumber">589</div><div style="width:2em;display:inline-block"></div>*/
<a name="line590"></a><div class="linenumber">590</div><div style="width:2em;display:inline-block"></div>this.nativeVideoWidth&nbsp;=&nbsp;0;
<a name="line591"></a><div class="linenumber">591</div>
<a name="line592"></a><div class="linenumber">592</div><div style="width:2em;display:inline-block"></div>/**&nbsp;The&nbsp;rooms&nbsp;the&nbsp;user&nbsp;is&nbsp;in.&nbsp;This&nbsp;only&nbsp;applies&nbsp;to&nbsp;room&nbsp;oriented&nbsp;applications&nbsp;and&nbsp;is&nbsp;set&nbsp;at&nbsp;the&nbsp;same
<a name="line593"></a><div class="linenumber">593</div><div style="width:2em;display:inline-block"></div>*&nbsp;time&nbsp;a&nbsp;token&nbsp;is&nbsp;received.
<a name="line594"></a><div class="linenumber">594</div><div style="width:2em;display:inline-block"></div>*/
<a name="line595"></a><div class="linenumber">595</div><div style="width:2em;display:inline-block"></div>this.roomJoin&nbsp;=&nbsp;{};
<a name="line596"></a><div class="linenumber">596</div>
<a name="line597"></a><div class="linenumber">597</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Checks&nbsp;if&nbsp;the&nbsp;supplied&nbsp;string&nbsp;is&nbsp;a&nbsp;valid&nbsp;user&nbsp;name&nbsp;(standard&nbsp;identifier&nbsp;rules)
<a name="line598"></a><div class="linenumber">598</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;name
<a name="line599"></a><div class="linenumber">599</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Boolean}&nbsp;true&nbsp;for&nbsp;a&nbsp;valid&nbsp;user&nbsp;name
<a name="line600"></a><div class="linenumber">600</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line601"></a><div class="linenumber">601</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;name&nbsp;=&nbsp;document.getElementById('nameField').value;
<a name="line602"></a><div class="linenumber">602</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;!easyrtc.isNameValid(name)){
<a name="line603"></a><div class="linenumber">603</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.error("Bad&nbsp;user&nbsp;name");
<a name="line604"></a><div class="linenumber">604</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line605"></a><div class="linenumber">605</div><div style="width:2em;display:inline-block"></div>*/
<a name="line606"></a><div class="linenumber">606</div><div style="width:2em;display:inline-block"></div>this.isNameValid&nbsp;=&nbsp;function(name)&nbsp;{
<a name="line607"></a><div class="linenumber">607</div><div style="width:4em;display:inline-block"></div>return&nbsp;self.usernameRegExp.test(name);
<a name="line608"></a><div class="linenumber">608</div><div style="width:2em;display:inline-block"></div>};
<a name="line609"></a><div class="linenumber">609</div>
<a name="line610"></a><div class="linenumber">610</div><div style="width:2em;display:inline-block"></div>/**
<a name="line611"></a><div class="linenumber">611</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;sets&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;cookie&nbsp;that&nbsp;client&nbsp;side&nbsp;library&nbsp;will&nbsp;look&nbsp;for
<a name="line612"></a><div class="linenumber">612</div><div style="width:2em;display:inline-block"></div>*&nbsp;and&nbsp;transmit&nbsp;back&nbsp;to&nbsp;the&nbsp;server&nbsp;as&nbsp;it's&nbsp;easyrtcsid&nbsp;in&nbsp;the&nbsp;first&nbsp;message.
<a name="line613"></a><div class="linenumber">613</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;cookieId
<a name="line614"></a><div class="linenumber">614</div><div style="width:2em;display:inline-block"></div>*/
<a name="line615"></a><div class="linenumber">615</div><div style="width:2em;display:inline-block"></div>this.setCookieId&nbsp;=&nbsp;function(cookieId)&nbsp;{
<a name="line616"></a><div class="linenumber">616</div><div style="width:4em;display:inline-block"></div>self.cookieId&nbsp;=&nbsp;cookieId;
<a name="line617"></a><div class="linenumber">617</div><div style="width:2em;display:inline-block"></div>};
<a name="line618"></a><div class="linenumber">618</div>
<a name="line619"></a><div class="linenumber">619</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line620"></a><div class="linenumber">620</div><div style="width:2em;display:inline-block"></div>this._desiredVideoProperties&nbsp;=&nbsp;{};&nbsp;//&nbsp;default&nbsp;camera
<a name="line621"></a><div class="linenumber">621</div>
<a name="line622"></a><div class="linenumber">622</div><div style="width:2em;display:inline-block"></div>/**
<a name="line623"></a><div class="linenumber">623</div><div style="width:2em;display:inline-block"></div>*&nbsp;Specify&nbsp;particular&nbsp;video&nbsp;source.&nbsp;Call&nbsp;this&nbsp;before&nbsp;you&nbsp;call&nbsp;easyrtc.initMediaSource().
<a name="line624"></a><div class="linenumber">624</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;videoSrcId&nbsp;is&nbsp;a&nbsp;id&nbsp;value&nbsp;from&nbsp;one&nbsp;of&nbsp;the&nbsp;entries&nbsp;fetched&nbsp;by&nbsp;getVideoSourceList.&nbsp;null&nbsp;for&nbsp;default.
<a name="line625"></a><div class="linenumber">625</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example&nbsp;easyrtc.setVideoSource(&nbsp;videoSrcId);
<a name="line626"></a><div class="linenumber">626</div><div style="width:2em;display:inline-block"></div>*/
<a name="line627"></a><div class="linenumber">627</div><div style="width:2em;display:inline-block"></div>this.setVideoSource&nbsp;=&nbsp;function(videoSrcId)&nbsp;{
<a name="line628"></a><div class="linenumber">628</div><div style="width:4em;display:inline-block"></div>self._desiredVideoProperties.videoSrcId&nbsp;=&nbsp;videoSrcId;
<a name="line629"></a><div class="linenumber">629</div><div style="width:4em;display:inline-block"></div>delete&nbsp;self._desiredVideoProperties.screenCapture;
<a name="line630"></a><div class="linenumber">630</div><div style="width:2em;display:inline-block"></div>};
<a name="line631"></a><div class="linenumber">631</div>
<a name="line632"></a><div class="linenumber">632</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line633"></a><div class="linenumber">633</div><div style="width:2em;display:inline-block"></div>this._desiredAudioProperties&nbsp;=&nbsp;{};&nbsp;//&nbsp;default&nbsp;camera
<a name="line634"></a><div class="linenumber">634</div>
<a name="line635"></a><div class="linenumber">635</div><div style="width:2em;display:inline-block"></div>/**
<a name="line636"></a><div class="linenumber">636</div><div style="width:2em;display:inline-block"></div>*&nbsp;Specify&nbsp;particular&nbsp;video&nbsp;source.&nbsp;Call&nbsp;this&nbsp;before&nbsp;you&nbsp;call&nbsp;easyrtc.initMediaSource().
<a name="line637"></a><div class="linenumber">637</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;audioSrcId&nbsp;is&nbsp;a&nbsp;id&nbsp;value&nbsp;from&nbsp;one&nbsp;of&nbsp;the&nbsp;entries&nbsp;fetched&nbsp;by&nbsp;getAudioSourceList.&nbsp;null&nbsp;for&nbsp;default.
<a name="line638"></a><div class="linenumber">638</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example&nbsp;easyrtc.setAudioSource(&nbsp;audioSrcId);
<a name="line639"></a><div class="linenumber">639</div><div style="width:2em;display:inline-block"></div>*/
<a name="line640"></a><div class="linenumber">640</div><div style="width:2em;display:inline-block"></div>this.setAudioSource&nbsp;=&nbsp;function(audioSrcId)&nbsp;{
<a name="line641"></a><div class="linenumber">641</div><div style="width:4em;display:inline-block"></div>self._desiredAudioProperties.audioSrcId&nbsp;=&nbsp;audioSrcId;
<a name="line642"></a><div class="linenumber">642</div><div style="width:2em;display:inline-block"></div>};
<a name="line643"></a><div class="linenumber">643</div>
<a name="line644"></a><div class="linenumber">644</div><div style="width:2em;display:inline-block"></div>/**&nbsp;This&nbsp;function&nbsp;is&nbsp;used&nbsp;to&nbsp;set&nbsp;the&nbsp;dimensions&nbsp;of&nbsp;the&nbsp;local&nbsp;camera,&nbsp;usually&nbsp;to&nbsp;get&nbsp;HD.
<a name="line645"></a><div class="linenumber">645</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;If&nbsp;called,&nbsp;it&nbsp;must&nbsp;be&nbsp;called&nbsp;before&nbsp;calling&nbsp;easyrtc.initMediaSource&nbsp;(explicitly&nbsp;or&nbsp;implicitly).
<a name="line646"></a><div class="linenumber">646</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;assuming&nbsp;it&nbsp;is&nbsp;supported.&nbsp;If&nbsp;you&nbsp;don't&nbsp;pass&nbsp;any&nbsp;parameters,&nbsp;it&nbsp;will&nbsp;use&nbsp;default&nbsp;camera&nbsp;dimensions.
<a name="line647"></a><div class="linenumber">647</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Number}&nbsp;width&nbsp;in&nbsp;pixels
<a name="line648"></a><div class="linenumber">648</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Number}&nbsp;height&nbsp;in&nbsp;pixels
<a name="line649"></a><div class="linenumber">649</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{number}&nbsp;frameRate&nbsp;is&nbsp;optional
<a name="line650"></a><div class="linenumber">650</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line651"></a><div class="linenumber">651</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoDims(1280,720);
<a name="line652"></a><div class="linenumber">652</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line653"></a><div class="linenumber">653</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoDims();
<a name="line654"></a><div class="linenumber">654</div><div style="width:2em;display:inline-block"></div>*/
<a name="line655"></a><div class="linenumber">655</div><div style="width:2em;display:inline-block"></div>this.setVideoDims&nbsp;=&nbsp;function(width,&nbsp;height,&nbsp;frameRate)&nbsp;{
<a name="line656"></a><div class="linenumber">656</div><div style="width:4em;display:inline-block"></div>self._desiredVideoProperties.width&nbsp;=&nbsp;width;
<a name="line657"></a><div class="linenumber">657</div><div style="width:4em;display:inline-block"></div>self._desiredVideoProperties.height&nbsp;=&nbsp;height;
<a name="line658"></a><div class="linenumber">658</div><div style="width:4em;display:inline-block"></div>if&nbsp;(frameRate&nbsp;!==&nbsp;undefined)&nbsp;{
<a name="line659"></a><div class="linenumber">659</div><div style="width:6em;display:inline-block"></div>self._desiredVideoProperties.frameRate&nbsp;=&nbsp;frameRate;
<a name="line660"></a><div class="linenumber">660</div><div style="width:4em;display:inline-block"></div>}
<a name="line661"></a><div class="linenumber">661</div><div style="width:2em;display:inline-block"></div>};
<a name="line662"></a><div class="linenumber">662</div>
<a name="line663"></a><div class="linenumber">663</div><div style="width:2em;display:inline-block"></div>/**&nbsp;This&nbsp;function&nbsp;requests&nbsp;that&nbsp;screen&nbsp;capturing&nbsp;be&nbsp;used&nbsp;to&nbsp;provide&nbsp;the&nbsp;local&nbsp;media&nbsp;source
<a name="line664"></a><div class="linenumber">664</div><div style="width:2em;display:inline-block"></div>*&nbsp;rather&nbsp;than&nbsp;a&nbsp;webcam.&nbsp;If&nbsp;you&nbsp;have&nbsp;multiple&nbsp;screens,&nbsp;they&nbsp;are&nbsp;composited&nbsp;side&nbsp;by&nbsp;side.
<a name="line665"></a><div class="linenumber">665</div><div style="width:2em;display:inline-block"></div>*&nbsp;Note:&nbsp;this&nbsp;functionality&nbsp;is&nbsp;not&nbsp;supported&nbsp;by&nbsp;Firefox,&nbsp;has&nbsp;to&nbsp;be&nbsp;called&nbsp;before&nbsp;calling&nbsp;initMediaSource&nbsp;(or&nbsp;easyApp),&nbsp;we&nbsp;don't&nbsp;currently&nbsp;supply&nbsp;a&nbsp;way&nbsp;to
<a name="line666"></a><div class="linenumber">666</div><div style="width:2em;display:inline-block"></div>*&nbsp;turn&nbsp;it&nbsp;off&nbsp;(once&nbsp;it's&nbsp;on),&nbsp;only&nbsp;works&nbsp;if&nbsp;the&nbsp;website&nbsp;is&nbsp;hosted&nbsp;SSL&nbsp;(https),&nbsp;and&nbsp;the&nbsp;image&nbsp;quality&nbsp;is&nbsp;rather
<a name="line667"></a><div class="linenumber">667</div><div style="width:2em;display:inline-block"></div>*&nbsp;poor&nbsp;going&nbsp;across&nbsp;a&nbsp;network&nbsp;because&nbsp;it&nbsp;tries&nbsp;to&nbsp;transmit&nbsp;so&nbsp;much&nbsp;data.&nbsp;In&nbsp;short,&nbsp;screen&nbsp;sharing
<a name="line668"></a><div class="linenumber">668</div><div style="width:2em;display:inline-block"></div>*&nbsp;through&nbsp;WebRTC&nbsp;isn't&nbsp;worth&nbsp;using&nbsp;at&nbsp;this&nbsp;point,&nbsp;but&nbsp;it&nbsp;is&nbsp;provided&nbsp;here&nbsp;so&nbsp;people&nbsp;can&nbsp;try&nbsp;it&nbsp;out.
<a name="line669"></a><div class="linenumber">669</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line670"></a><div class="linenumber">670</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setScreenCapture();
<a name="line671"></a><div class="linenumber">671</div><div style="width:2em;display:inline-block"></div>*&nbsp;@deprecated:&nbsp;use&nbsp;easyrtc.initScreenCapture&nbsp;(same&nbsp;parameters&nbsp;as&nbsp;easyrtc.initMediaSource.
<a name="line672"></a><div class="linenumber">672</div><div style="width:2em;display:inline-block"></div>*/
<a name="line673"></a><div class="linenumber">673</div><div style="width:2em;display:inline-block"></div>this.setScreenCapture&nbsp;=&nbsp;function(enableScreenCapture)&nbsp;{
<a name="line674"></a><div class="linenumber">674</div><div style="width:4em;display:inline-block"></div>self._desiredVideoProperties.screenCapture&nbsp;=&nbsp;(enableScreenCapture&nbsp;!==&nbsp;false);
<a name="line675"></a><div class="linenumber">675</div><div style="width:2em;display:inline-block"></div>};
<a name="line676"></a><div class="linenumber">676</div>
<a name="line677"></a><div class="linenumber">677</div><div style="width:2em;display:inline-block"></div>/**
<a name="line678"></a><div class="linenumber">678</div><div style="width:2em;display:inline-block"></div>*&nbsp;Builds&nbsp;the&nbsp;constraint&nbsp;object&nbsp;passed&nbsp;to&nbsp;getUserMedia.
<a name="line679"></a><div class="linenumber">679</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;mediaConstraints
<a name="line680"></a><div class="linenumber">680</div><div style="width:2em;display:inline-block"></div>*/
<a name="line681"></a><div class="linenumber">681</div><div style="width:2em;display:inline-block"></div>self.getUserMediaConstraints&nbsp;=&nbsp;function()&nbsp;{
<a name="line682"></a><div class="linenumber">682</div><div style="width:4em;display:inline-block"></div>var&nbsp;constraints&nbsp;=&nbsp;{};
<a name="line683"></a><div class="linenumber">683</div><div style="width:4em;display:inline-block"></div>//
<a name="line684"></a><div class="linenumber">684</div><div style="width:4em;display:inline-block"></div>//&nbsp;_presetMediaConstraints&nbsp;allow&nbsp;you&nbsp;to&nbsp;provide&nbsp;your&nbsp;own&nbsp;constraints&nbsp;to&nbsp;be&nbsp;used
<a name="line685"></a><div class="linenumber">685</div><div style="width:4em;display:inline-block"></div>//&nbsp;with&nbsp;initMediaSource.
<a name="line686"></a><div class="linenumber">686</div><div style="width:4em;display:inline-block"></div>//
<a name="line687"></a><div class="linenumber">687</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self._presetMediaConstraints)&nbsp;{
<a name="line688"></a><div class="linenumber">688</div><div style="width:6em;display:inline-block"></div>constraints&nbsp;=&nbsp;self._presetMediaConstraints;
<a name="line689"></a><div class="linenumber">689</div><div style="width:6em;display:inline-block"></div>delete&nbsp;self._presetMediaConstraints;
<a name="line690"></a><div class="linenumber">690</div><div style="width:6em;display:inline-block"></div>return&nbsp;constraints;
<a name="line691"></a><div class="linenumber">691</div><div style="width:4em;display:inline-block"></div>}
<a name="line692"></a><div class="linenumber">692</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(self._desiredVideoProperties.screenCapture)&nbsp;{
<a name="line693"></a><div class="linenumber">693</div><div style="width:6em;display:inline-block"></div>return&nbsp;{
<a name="line694"></a><div class="linenumber">694</div><div style="width:8em;display:inline-block"></div>video:&nbsp;{
<a name="line695"></a><div class="linenumber">695</div><div style="width:10em;display:inline-block"></div>mandatory:&nbsp;{
<a name="line696"></a><div class="linenumber">696</div><div style="width:12em;display:inline-block"></div>chromeMediaSource:&nbsp;'screen',
<a name="line697"></a><div class="linenumber">697</div><div style="width:12em;display:inline-block"></div>maxWidth:&nbsp;screen.width,
<a name="line698"></a><div class="linenumber">698</div><div style="width:12em;display:inline-block"></div>maxHeight:&nbsp;screen.height,
<a name="line699"></a><div class="linenumber">699</div><div style="width:12em;display:inline-block"></div>minWidth:&nbsp;screen.width,
<a name="line700"></a><div class="linenumber">700</div><div style="width:12em;display:inline-block"></div>minHeight:&nbsp;screen.height,
<a name="line701"></a><div class="linenumber">701</div><div style="width:12em;display:inline-block"></div>minFrameRate:&nbsp;1,
<a name="line702"></a><div class="linenumber">702</div><div style="width:12em;display:inline-block"></div>maxFrameRate:&nbsp;5},
<a name="line703"></a><div class="linenumber">703</div><div style="width:10em;display:inline-block"></div>optional:&nbsp;[]
<a name="line704"></a><div class="linenumber">704</div><div style="width:8em;display:inline-block"></div>},
<a name="line705"></a><div class="linenumber">705</div><div style="width:8em;display:inline-block"></div>audio:&nbsp;false
<a name="line706"></a><div class="linenumber">706</div><div style="width:6em;display:inline-block"></div>};
<a name="line707"></a><div class="linenumber">707</div><div style="width:4em;display:inline-block"></div>}
<a name="line708"></a><div class="linenumber">708</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(!self.videoEnabled)&nbsp;{
<a name="line709"></a><div class="linenumber">709</div><div style="width:6em;display:inline-block"></div>constraints.video&nbsp;=&nbsp;false;
<a name="line710"></a><div class="linenumber">710</div><div style="width:4em;display:inline-block"></div>}
<a name="line711"></a><div class="linenumber">711</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line712"></a><div class="linenumber">712</div>
<a name="line713"></a><div class="linenumber">713</div><div style="width:6em;display:inline-block"></div>//&nbsp;Tested&nbsp;Firefox&nbsp;49&nbsp;and&nbsp;MS&nbsp;Edge&nbsp;require&nbsp;minFrameRate&nbsp;and&nbsp;maxFrameRate&nbsp;
<a name="line714"></a><div class="linenumber">714</div><div style="width:6em;display:inline-block"></div>//&nbsp;instead&nbsp;max,min,ideal&nbsp;that&nbsp;cause&nbsp;GetUserMedia&nbsp;failure.
<a name="line715"></a><div class="linenumber">715</div><div style="width:6em;display:inline-block"></div>//&nbsp;Until&nbsp;confirmed&nbsp;both&nbsp;browser&nbsp;support&nbsp;idea,max&nbsp;and&nbsp;min&nbsp;we&nbsp;need&nbsp;this.
<a name="line716"></a><div class="linenumber">716</div><div style="width:6em;display:inline-block"></div>if&nbsp;(
<a name="line717"></a><div class="linenumber">717</div><div style="width:8em;display:inline-block"></div>adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line718"></a><div class="linenumber">718</div><div style="width:10em;display:inline-block"></div>(adapter.browserDetails.browser&nbsp;===&nbsp;"firefox"&nbsp;||&nbsp;adapter.browserDetails.browser&nbsp;===&nbsp;"edge")
<a name="line719"></a><div class="linenumber">719</div><div style="width:6em;display:inline-block"></div>)&nbsp;{
<a name="line720"></a><div class="linenumber">720</div><div style="width:8em;display:inline-block"></div>constraints.video&nbsp;=&nbsp;{};
<a name="line721"></a><div class="linenumber">721</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.width)&nbsp;{
<a name="line722"></a><div class="linenumber">722</div><div style="width:10em;display:inline-block"></div>constraints.video.width&nbsp;=&nbsp;self._desiredVideoProperties.width;
<a name="line723"></a><div class="linenumber">723</div><div style="width:8em;display:inline-block"></div>}
<a name="line724"></a><div class="linenumber">724</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.height)&nbsp;{
<a name="line725"></a><div class="linenumber">725</div><div style="width:10em;display:inline-block"></div>constraints.video.height&nbsp;=&nbsp;self._desiredVideoProperties.height;
<a name="line726"></a><div class="linenumber">726</div><div style="width:8em;display:inline-block"></div>}
<a name="line727"></a><div class="linenumber">727</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.frameRate)&nbsp;{
<a name="line728"></a><div class="linenumber">728</div><div style="width:10em;display:inline-block"></div>constraints.video.frameRate&nbsp;=&nbsp;{&nbsp;
<a name="line729"></a><div class="linenumber">729</div><div style="width:12em;display:inline-block"></div>minFrameRate:&nbsp;self._desiredVideoProperties.frameRate,
<a name="line730"></a><div class="linenumber">730</div><div style="width:12em;display:inline-block"></div>maxFrameRate:&nbsp;self._desiredVideoProperties.frameRate
<a name="line731"></a><div class="linenumber">731</div><div style="width:10em;display:inline-block"></div>};
<a name="line732"></a><div class="linenumber">732</div><div style="width:8em;display:inline-block"></div>}
<a name="line733"></a><div class="linenumber">733</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.videoSrcId)&nbsp;{
<a name="line734"></a><div class="linenumber">734</div><div style="width:10em;display:inline-block"></div>constraints.video.deviceId&nbsp;=&nbsp;self._desiredVideoProperties.videoSrcId;
<a name="line735"></a><div class="linenumber">735</div><div style="width:8em;display:inline-block"></div>}
<a name="line736"></a><div class="linenumber">736</div>
<a name="line737"></a><div class="linenumber">737</div><div style="width:6em;display:inline-block"></div>//&nbsp;chrome&nbsp;and&nbsp;opera
<a name="line738"></a><div class="linenumber">738</div><div style="width:6em;display:inline-block"></div>}&nbsp;else&nbsp;{&nbsp;
<a name="line739"></a><div class="linenumber">739</div><div style="width:8em;display:inline-block"></div>constraints.video&nbsp;=&nbsp;{};
<a name="line740"></a><div class="linenumber">740</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.width)&nbsp;{
<a name="line741"></a><div class="linenumber">741</div><div style="width:10em;display:inline-block"></div>constraints.video.width&nbsp;=&nbsp;{&nbsp;
<a name="line742"></a><div class="linenumber">742</div><div style="width:12em;display:inline-block"></div>max:&nbsp;self._desiredVideoProperties.width,
<a name="line743"></a><div class="linenumber">743</div><div style="width:12em;display:inline-block"></div>min&nbsp;:&nbsp;self._desiredVideoProperties.width,
<a name="line744"></a><div class="linenumber">744</div><div style="width:12em;display:inline-block"></div>ideal&nbsp;:&nbsp;self._desiredVideoProperties.width&nbsp;
<a name="line745"></a><div class="linenumber">745</div><div style="width:10em;display:inline-block"></div>};
<a name="line746"></a><div class="linenumber">746</div><div style="width:8em;display:inline-block"></div>}
<a name="line747"></a><div class="linenumber">747</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.height)&nbsp;{
<a name="line748"></a><div class="linenumber">748</div><div style="width:10em;display:inline-block"></div>constraints.video.height&nbsp;=&nbsp;{
<a name="line749"></a><div class="linenumber">749</div><div style="width:12em;display:inline-block"></div>max:&nbsp;self._desiredVideoProperties.height,
<a name="line750"></a><div class="linenumber">750</div><div style="width:12em;display:inline-block"></div>min:&nbsp;self._desiredVideoProperties.height,
<a name="line751"></a><div class="linenumber">751</div><div style="width:12em;display:inline-block"></div>ideal:&nbsp;self._desiredVideoProperties.height
<a name="line752"></a><div class="linenumber">752</div><div style="width:10em;display:inline-block"></div>};
<a name="line753"></a><div class="linenumber">753</div><div style="width:8em;display:inline-block"></div>}
<a name="line754"></a><div class="linenumber">754</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.frameRate)&nbsp;{
<a name="line755"></a><div class="linenumber">755</div><div style="width:10em;display:inline-block"></div>constraints.video.frameRate&nbsp;=&nbsp;{
<a name="line756"></a><div class="linenumber">756</div><div style="width:12em;display:inline-block"></div>max:&nbsp;self._desiredVideoProperties.frameRate,
<a name="line757"></a><div class="linenumber">757</div><div style="width:12em;display:inline-block"></div>ideal:&nbsp;self._desiredVideoProperties.frameRate
<a name="line758"></a><div class="linenumber">758</div><div style="width:10em;display:inline-block"></div>};
<a name="line759"></a><div class="linenumber">759</div><div style="width:8em;display:inline-block"></div>}
<a name="line760"></a><div class="linenumber">760</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.videoSrcId)&nbsp;{
<a name="line761"></a><div class="linenumber">761</div><div style="width:10em;display:inline-block"></div>constraints.video.deviceId&nbsp;=&nbsp;self._desiredVideoProperties.videoSrcId;
<a name="line762"></a><div class="linenumber">762</div><div style="width:8em;display:inline-block"></div>}
<a name="line763"></a><div class="linenumber">763</div><div style="width:8em;display:inline-block"></div>//&nbsp;hack&nbsp;for&nbsp;opera
<a name="line764"></a><div class="linenumber">764</div><div style="width:8em;display:inline-block"></div>if&nbsp;(Object.keys(constraints.video).length&nbsp;===&nbsp;0&nbsp;)&nbsp;{
<a name="line765"></a><div class="linenumber">765</div><div style="width:10em;display:inline-block"></div>constraints.video&nbsp;=&nbsp;true;
<a name="line766"></a><div class="linenumber">766</div><div style="width:8em;display:inline-block"></div>}
<a name="line767"></a><div class="linenumber">767</div><div style="width:6em;display:inline-block"></div>}
<a name="line768"></a><div class="linenumber">768</div><div style="width:4em;display:inline-block"></div>}
<a name="line769"></a><div class="linenumber">769</div>
<a name="line770"></a><div class="linenumber">770</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.audioEnabled)&nbsp;{
<a name="line771"></a><div class="linenumber">771</div><div style="width:6em;display:inline-block"></div>constraints.audio&nbsp;=&nbsp;false;
<a name="line772"></a><div class="linenumber">772</div><div style="width:4em;display:inline-block"></div>}
<a name="line773"></a><div class="linenumber">773</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line774"></a><div class="linenumber">774</div><div style="width:6em;display:inline-block"></div>if&nbsp;(adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;&nbsp;adapter.browserDetails.browser&nbsp;===&nbsp;"firefox")&nbsp;{
<a name="line775"></a><div class="linenumber">775</div><div style="width:8em;display:inline-block"></div>constraints.audio&nbsp;=&nbsp;{};
<a name="line776"></a><div class="linenumber">776</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredAudioProperties.audioSrcId)&nbsp;{
<a name="line777"></a><div class="linenumber">777</div><div style="width:10em;display:inline-block"></div>constraints.audio.deviceId&nbsp;=&nbsp;self._desiredAudioProperties.audioSrcId;
<a name="line778"></a><div class="linenumber">778</div><div style="width:8em;display:inline-block"></div>}
<a name="line779"></a><div class="linenumber">779</div><div style="width:6em;display:inline-block"></div>}
<a name="line780"></a><div class="linenumber">780</div><div style="width:6em;display:inline-block"></div>else&nbsp;{&nbsp;//&nbsp;chrome&nbsp;and&nbsp;opera
<a name="line781"></a><div class="linenumber">781</div><div style="width:8em;display:inline-block"></div>constraints.audio&nbsp;=&nbsp;{mandatory:&nbsp;{},&nbsp;optional:&nbsp;[]};
<a name="line782"></a><div class="linenumber">782</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self._desiredAudioProperties.audioSrcId)&nbsp;{
<a name="line783"></a><div class="linenumber">783</div><div style="width:10em;display:inline-block"></div>constraints.audio.optional&nbsp;=&nbsp;constraints.audio.optional&nbsp;||&nbsp;[];
<a name="line784"></a><div class="linenumber">784</div><div style="width:10em;display:inline-block"></div>constraints.audio.optional.push({deviceId:&nbsp;self._desiredAudioProperties.audioSrcId});
<a name="line785"></a><div class="linenumber">785</div><div style="width:8em;display:inline-block"></div>}
<a name="line786"></a><div class="linenumber">786</div><div style="width:6em;display:inline-block"></div>}
<a name="line787"></a><div class="linenumber">787</div><div style="width:4em;display:inline-block"></div>}
<a name="line788"></a><div class="linenumber">788</div><div style="width:4em;display:inline-block"></div>return&nbsp;constraints;
<a name="line789"></a><div class="linenumber">789</div><div style="width:2em;display:inline-block"></div>};
<a name="line790"></a><div class="linenumber">790</div>
<a name="line791"></a><div class="linenumber">791</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Set&nbsp;the&nbsp;application&nbsp;name.&nbsp;Applications&nbsp;can&nbsp;only&nbsp;communicate&nbsp;with&nbsp;other&nbsp;applications
<a name="line792"></a><div class="linenumber">792</div><div style="width:2em;display:inline-block"></div>*&nbsp;that&nbsp;share&nbsp;the&nbsp;same&nbsp;API&nbsp;Key&nbsp;and&nbsp;application&nbsp;name.&nbsp;There&nbsp;is&nbsp;no&nbsp;predefined&nbsp;set&nbsp;of&nbsp;application
<a name="line793"></a><div class="linenumber">793</div><div style="width:2em;display:inline-block"></div>*&nbsp;names.&nbsp;Maximum&nbsp;length&nbsp;is
<a name="line794"></a><div class="linenumber">794</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;name
<a name="line795"></a><div class="linenumber">795</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line796"></a><div class="linenumber">796</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setApplicationName('simpleAudioVideo');
<a name="line797"></a><div class="linenumber">797</div><div style="width:2em;display:inline-block"></div>*/
<a name="line798"></a><div class="linenumber">798</div><div style="width:2em;display:inline-block"></div>this.setApplicationName&nbsp;=&nbsp;function(name)&nbsp;{
<a name="line799"></a><div class="linenumber">799</div><div style="width:4em;display:inline-block"></div>self.applicationName&nbsp;=&nbsp;name;
<a name="line800"></a><div class="linenumber">800</div><div style="width:2em;display:inline-block"></div>};
<a name="line801"></a><div class="linenumber">801</div>
<a name="line802"></a><div class="linenumber">802</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Enable&nbsp;or&nbsp;disable&nbsp;logging&nbsp;to&nbsp;the&nbsp;console.
<a name="line803"></a><div class="linenumber">803</div><div style="width:2em;display:inline-block"></div>*&nbsp;Note:&nbsp;if&nbsp;you&nbsp;want&nbsp;to&nbsp;control&nbsp;the&nbsp;printing&nbsp;of&nbsp;debug&nbsp;messages,&nbsp;override&nbsp;the
<a name="line804"></a><div class="linenumber">804</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.debugPrinter&nbsp;variable&nbsp;with&nbsp;a&nbsp;function&nbsp;that&nbsp;takes&nbsp;a&nbsp;message&nbsp;string&nbsp;as&nbsp;it's&nbsp;argument.
<a name="line805"></a><div class="linenumber">805</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;exactly&nbsp;what&nbsp;easyrtc.enableDebug&nbsp;does&nbsp;when&nbsp;it's&nbsp;enable&nbsp;argument&nbsp;is&nbsp;true.
<a name="line806"></a><div class="linenumber">806</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enable&nbsp;-&nbsp;true&nbsp;to&nbsp;turn&nbsp;on&nbsp;debugging,&nbsp;false&nbsp;to&nbsp;turn&nbsp;off&nbsp;debugging.&nbsp;Default&nbsp;is&nbsp;false.
<a name="line807"></a><div class="linenumber">807</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line808"></a><div class="linenumber">808</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.enableDebug(true);
<a name="line809"></a><div class="linenumber">809</div><div style="width:2em;display:inline-block"></div>*/
<a name="line810"></a><div class="linenumber">810</div><div style="width:2em;display:inline-block"></div>this.enableDebug&nbsp;=&nbsp;function(enable)&nbsp;{
<a name="line811"></a><div class="linenumber">811</div><div style="width:4em;display:inline-block"></div>if&nbsp;(enable)&nbsp;{
<a name="line812"></a><div class="linenumber">812</div><div style="width:6em;display:inline-block"></div>self.debugPrinter&nbsp;=&nbsp;function(message,&nbsp;obj)&nbsp;{
<a name="line813"></a><div class="linenumber">813</div><div style="width:8em;display:inline-block"></div>var&nbsp;now&nbsp;=&nbsp;new&nbsp;Date().toISOString();
<a name="line814"></a><div class="linenumber">814</div><div style="width:8em;display:inline-block"></div>var&nbsp;stackString&nbsp;=&nbsp;new&nbsp;Error().stack;
<a name="line815"></a><div class="linenumber">815</div><div style="width:8em;display:inline-block"></div>var&nbsp;srcLine&nbsp;=&nbsp;"location&nbsp;unknown";
<a name="line816"></a><div class="linenumber">816</div><div style="width:8em;display:inline-block"></div>if&nbsp;(stackString)&nbsp;{
<a name="line817"></a><div class="linenumber">817</div><div style="width:10em;display:inline-block"></div>var&nbsp;stackFrameStrings&nbsp;=&nbsp;stackString.split('\n');
<a name="line818"></a><div class="linenumber">818</div><div style="width:10em;display:inline-block"></div>srcLine&nbsp;=&nbsp;"";
<a name="line819"></a><div class="linenumber">819</div><div style="width:10em;display:inline-block"></div>if&nbsp;(stackFrameStrings.length&nbsp;&gt;=&nbsp;5)&nbsp;{
<a name="line820"></a><div class="linenumber">820</div><div style="width:12em;display:inline-block"></div>srcLine&nbsp;=&nbsp;stackFrameStrings[4];
<a name="line821"></a><div class="linenumber">821</div><div style="width:10em;display:inline-block"></div>}
<a name="line822"></a><div class="linenumber">822</div><div style="width:8em;display:inline-block"></div>}
<a name="line823"></a><div class="linenumber">823</div>
<a name="line824"></a><div class="linenumber">824</div><div style="width:8em;display:inline-block"></div>console.log("debug&nbsp;"&nbsp;+&nbsp;now&nbsp;+&nbsp;"&nbsp;:&nbsp;"&nbsp;+&nbsp;message&nbsp;+&nbsp;"&nbsp;["&nbsp;+&nbsp;srcLine&nbsp;+&nbsp;"]");
<a name="line825"></a><div class="linenumber">825</div>
<a name="line826"></a><div class="linenumber">826</div><div style="width:8em;display:inline-block"></div>if&nbsp;(typeof&nbsp;obj&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line827"></a><div class="linenumber">827</div><div style="width:10em;display:inline-block"></div>console.log("debug&nbsp;"&nbsp;+&nbsp;now&nbsp;+&nbsp;"&nbsp;:&nbsp;",&nbsp;obj);
<a name="line828"></a><div class="linenumber">828</div><div style="width:8em;display:inline-block"></div>}
<a name="line829"></a><div class="linenumber">829</div><div style="width:6em;display:inline-block"></div>};
<a name="line830"></a><div class="linenumber">830</div><div style="width:4em;display:inline-block"></div>}
<a name="line831"></a><div class="linenumber">831</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line832"></a><div class="linenumber">832</div><div style="width:6em;display:inline-block"></div>self.debugPrinter&nbsp;=&nbsp;null;
<a name="line833"></a><div class="linenumber">833</div><div style="width:4em;display:inline-block"></div>}
<a name="line834"></a><div class="linenumber">834</div><div style="width:2em;display:inline-block"></div>};
<a name="line835"></a><div class="linenumber">835</div>
<a name="line836"></a><div class="linenumber">836</div><div style="width:2em;display:inline-block"></div>/**
<a name="line837"></a><div class="linenumber">837</div><div style="width:2em;display:inline-block"></div>*&nbsp;Determines&nbsp;if&nbsp;the&nbsp;local&nbsp;browser&nbsp;supports&nbsp;WebRTC&nbsp;GetUserMedia&nbsp;(access&nbsp;to&nbsp;camera&nbsp;and&nbsp;microphone).
<a name="line838"></a><div class="linenumber">838</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Boolean}&nbsp;True&nbsp;getUserMedia&nbsp;is&nbsp;supported.
<a name="line839"></a><div class="linenumber">839</div><div style="width:2em;display:inline-block"></div>*/
<a name="line840"></a><div class="linenumber">840</div><div style="width:2em;display:inline-block"></div>this.supportsGetUserMedia&nbsp;=&nbsp;function()&nbsp;{
<a name="line841"></a><div class="linenumber">841</div><div style="width:4em;display:inline-block"></div>return&nbsp;typeof&nbsp;navigator.getUserMedia&nbsp;!==&nbsp;'undefined';
<a name="line842"></a><div class="linenumber">842</div><div style="width:2em;display:inline-block"></div>};
<a name="line843"></a><div class="linenumber">843</div>
<a name="line844"></a><div class="linenumber">844</div><div style="width:2em;display:inline-block"></div>/**
<a name="line845"></a><div class="linenumber">845</div><div style="width:2em;display:inline-block"></div>*&nbsp;Determines&nbsp;if&nbsp;the&nbsp;local&nbsp;browser&nbsp;supports&nbsp;WebRTC&nbsp;Peer&nbsp;connections&nbsp;to&nbsp;the&nbsp;extent&nbsp;of&nbsp;being&nbsp;able&nbsp;to&nbsp;do&nbsp;video&nbsp;chats.
<a name="line846"></a><div class="linenumber">846</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Boolean}&nbsp;True&nbsp;if&nbsp;Peer&nbsp;connections&nbsp;are&nbsp;supported.
<a name="line847"></a><div class="linenumber">847</div><div style="width:2em;display:inline-block"></div>*/
<a name="line848"></a><div class="linenumber">848</div><div style="width:2em;display:inline-block"></div>this.supportsPeerConnections&nbsp;=&nbsp;function()&nbsp;{
<a name="line849"></a><div class="linenumber">849</div><div style="width:4em;display:inline-block"></div>return&nbsp;typeof&nbsp;RTCPeerConnection&nbsp;!==&nbsp;'undefined';
<a name="line850"></a><div class="linenumber">850</div><div style="width:2em;display:inline-block"></div>};
<a name="line851"></a><div class="linenumber">851</div>
<a name="line852"></a><div class="linenumber">852</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Determines&nbsp;whether&nbsp;the&nbsp;current&nbsp;browser&nbsp;supports&nbsp;the&nbsp;new&nbsp;data&nbsp;channels.
<a name="line853"></a><div class="linenumber">853</div><div style="width:2em;display:inline-block"></div>*&nbsp;EasyRTC&nbsp;will&nbsp;not&nbsp;open&nbsp;up&nbsp;connections&nbsp;with&nbsp;the&nbsp;old&nbsp;data&nbsp;channels.
<a name="line854"></a><div class="linenumber">854</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Boolean}
<a name="line855"></a><div class="linenumber">855</div><div style="width:2em;display:inline-block"></div>*/
<a name="line856"></a><div class="linenumber">856</div><div style="width:2em;display:inline-block"></div>this.supportsDataChannels&nbsp;=&nbsp;function()&nbsp;{
<a name="line857"></a><div class="linenumber">857</div>
<a name="line858"></a><div class="linenumber">858</div><div style="width:4em;display:inline-block"></div>var&nbsp;hasCreateDataChannel&nbsp;=&nbsp;false;
<a name="line859"></a><div class="linenumber">859</div>
<a name="line860"></a><div class="linenumber">860</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.supportsPeerConnections())&nbsp;{
<a name="line861"></a><div class="linenumber">861</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line862"></a><div class="linenumber">862</div><div style="width:8em;display:inline-block"></div>var&nbsp;peer&nbsp;=&nbsp;new&nbsp;RTCPeerConnection({iceServers:&nbsp;[]},&nbsp;{});
<a name="line863"></a><div class="linenumber">863</div><div style="width:8em;display:inline-block"></div>hasCreateDataChannel&nbsp;=&nbsp;typeof&nbsp;peer.createDataChannel&nbsp;!==&nbsp;'undefined';
<a name="line864"></a><div class="linenumber">864</div><div style="width:8em;display:inline-block"></div>peer.close();
<a name="line865"></a><div class="linenumber">865</div><div style="width:6em;display:inline-block"></div>}
<a name="line866"></a><div class="linenumber">866</div><div style="width:6em;display:inline-block"></div>catch&nbsp;(err)&nbsp;{
<a name="line867"></a><div class="linenumber">867</div><div style="width:8em;display:inline-block"></div>//&nbsp;Ignore&nbsp;possible&nbsp;RTCPeerConnection.close&nbsp;error
<a name="line868"></a><div class="linenumber">868</div><div style="width:8em;display:inline-block"></div>//&nbsp;hasCreateDataChannel&nbsp;should&nbsp;reflect&nbsp;the&nbsp;feature&nbsp;state&nbsp;still.
<a name="line869"></a><div class="linenumber">869</div><div style="width:6em;display:inline-block"></div>}
<a name="line870"></a><div class="linenumber">870</div><div style="width:4em;display:inline-block"></div>}
<a name="line871"></a><div class="linenumber">871</div>
<a name="line872"></a><div class="linenumber">872</div><div style="width:4em;display:inline-block"></div>return&nbsp;hasCreateDataChannel;
<a name="line873"></a><div class="linenumber">873</div><div style="width:2em;display:inline-block"></div>};
<a name="line874"></a><div class="linenumber">874</div>
<a name="line875"></a><div class="linenumber">875</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line876"></a><div class="linenumber">876</div><div style="width:2em;display:inline-block"></div>//
<a name="line877"></a><div class="linenumber">877</div><div style="width:2em;display:inline-block"></div>//&nbsp;Experimental&nbsp;function&nbsp;to&nbsp;determine&nbsp;if&nbsp;statistics&nbsp;gathering&nbsp;is&nbsp;supported.
<a name="line878"></a><div class="linenumber">878</div><div style="width:2em;display:inline-block"></div>//
<a name="line879"></a><div class="linenumber">879</div><div style="width:2em;display:inline-block"></div>this.supportsStatistics&nbsp;=&nbsp;function()&nbsp;{
<a name="line880"></a><div class="linenumber">880</div>
<a name="line881"></a><div class="linenumber">881</div><div style="width:4em;display:inline-block"></div>var&nbsp;hasGetStats&nbsp;=&nbsp;false;
<a name="line882"></a><div class="linenumber">882</div>
<a name="line883"></a><div class="linenumber">883</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.supportsPeerConnections())&nbsp;{
<a name="line884"></a><div class="linenumber">884</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line885"></a><div class="linenumber">885</div><div style="width:8em;display:inline-block"></div>var&nbsp;peer&nbsp;=&nbsp;new&nbsp;RTCPeerConnection({iceServers:&nbsp;[]},&nbsp;{});
<a name="line886"></a><div class="linenumber">886</div><div style="width:8em;display:inline-block"></div>hasGetStats&nbsp;=&nbsp;typeof&nbsp;peer.getStats&nbsp;!==&nbsp;'undefined';
<a name="line887"></a><div class="linenumber">887</div><div style="width:8em;display:inline-block"></div>peer.close();
<a name="line888"></a><div class="linenumber">888</div><div style="width:6em;display:inline-block"></div>}
<a name="line889"></a><div class="linenumber">889</div><div style="width:6em;display:inline-block"></div>catch&nbsp;(err)&nbsp;{
<a name="line890"></a><div class="linenumber">890</div><div style="width:8em;display:inline-block"></div>//&nbsp;Ingore&nbsp;possible&nbsp;RTCPeerConnection.close&nbsp;error
<a name="line891"></a><div class="linenumber">891</div><div style="width:8em;display:inline-block"></div>//&nbsp;hasCreateDataChannel&nbsp;should&nbsp;reflect&nbsp;the&nbsp;feature&nbsp;state&nbsp;still.
<a name="line892"></a><div class="linenumber">892</div><div style="width:6em;display:inline-block"></div>}
<a name="line893"></a><div class="linenumber">893</div><div style="width:4em;display:inline-block"></div>}
<a name="line894"></a><div class="linenumber">894</div>
<a name="line895"></a><div class="linenumber">895</div><div style="width:4em;display:inline-block"></div>return&nbsp;hasGetStats;
<a name="line896"></a><div class="linenumber">896</div><div style="width:2em;display:inline-block"></div>};
<a name="line897"></a><div class="linenumber">897</div>
<a name="line898"></a><div class="linenumber">898</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line899"></a><div class="linenumber">899</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Array}&nbsp;pc_config&nbsp;ice&nbsp;configuration&nbsp;array
<a name="line900"></a><div class="linenumber">900</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;optionalStuff&nbsp;peer&nbsp;constraints.
<a name="line901"></a><div class="linenumber">901</div><div style="width:2em;display:inline-block"></div>*/
<a name="line902"></a><div class="linenumber">902</div><div style="width:2em;display:inline-block"></div>this.createRTCPeerConnection&nbsp;=&nbsp;function(pc_config,&nbsp;optionalStuff)&nbsp;{
<a name="line903"></a><div class="linenumber">903</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.supportsPeerConnections())&nbsp;{
<a name="line904"></a><div class="linenumber">904</div><div style="width:6em;display:inline-block"></div>return&nbsp;new&nbsp;RTCPeerConnection(pc_config,&nbsp;optionalStuff);
<a name="line905"></a><div class="linenumber">905</div><div style="width:4em;display:inline-block"></div>}
<a name="line906"></a><div class="linenumber">906</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line907"></a><div class="linenumber">907</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Your&nbsp;browser&nbsp;doesn't&nbsp;support&nbsp;webRTC&nbsp;(RTCPeerConnection)";
<a name="line908"></a><div class="linenumber">908</div><div style="width:4em;display:inline-block"></div>}
<a name="line909"></a><div class="linenumber">909</div><div style="width:2em;display:inline-block"></div>};
<a name="line910"></a><div class="linenumber">910</div>
<a name="line911"></a><div class="linenumber">911</div><div style="width:2em;display:inline-block"></div>//
<a name="line912"></a><div class="linenumber">912</div><div style="width:2em;display:inline-block"></div>//&nbsp;this&nbsp;should&nbsp;really&nbsp;be&nbsp;part&nbsp;of&nbsp;adapter.js
<a name="line913"></a><div class="linenumber">913</div><div style="width:2em;display:inline-block"></div>//&nbsp;Versions&nbsp;of&nbsp;chrome&nbsp;&lt;&nbsp;31&nbsp;don't&nbsp;support&nbsp;reliable&nbsp;data&nbsp;channels&nbsp;transport.
<a name="line914"></a><div class="linenumber">914</div><div style="width:2em;display:inline-block"></div>//&nbsp;Firefox&nbsp;does.
<a name="line915"></a><div class="linenumber">915</div><div style="width:2em;display:inline-block"></div>//
<a name="line916"></a><div class="linenumber">916</div><div style="width:2em;display:inline-block"></div>this.getDatachannelConstraints&nbsp;=&nbsp;function()&nbsp;{
<a name="line917"></a><div class="linenumber">917</div><div style="width:4em;display:inline-block"></div>return&nbsp;{
<a name="line918"></a><div class="linenumber">918</div><div style="width:6em;display:inline-block"></div>reliable:&nbsp;adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line919"></a><div class="linenumber">919</div><div style="width:8em;display:inline-block"></div>adapter.browserDetails.browser&nbsp;!==&nbsp;"chrome"&nbsp;&amp;&amp;
<a name="line920"></a><div class="linenumber">920</div><div style="width:10em;display:inline-block"></div>adapter.browserDetails.version&nbsp;&lt;&nbsp;31
<a name="line921"></a><div class="linenumber">921</div><div style="width:4em;display:inline-block"></div>};
<a name="line922"></a><div class="linenumber">922</div><div style="width:2em;display:inline-block"></div>};
<a name="line923"></a><div class="linenumber">923</div>
<a name="line924"></a><div class="linenumber">924</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line925"></a><div class="linenumber">925</div><div style="width:2em;display:inline-block"></div>haveAudioVideo&nbsp;=&nbsp;{
<a name="line926"></a><div class="linenumber">926</div><div style="width:4em;display:inline-block"></div>audio:&nbsp;false,
<a name="line927"></a><div class="linenumber">927</div><div style="width:4em;display:inline-block"></div>video:&nbsp;false
<a name="line928"></a><div class="linenumber">928</div><div style="width:2em;display:inline-block"></div>};
<a name="line929"></a><div class="linenumber">929</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line930"></a><div class="linenumber">930</div><div style="width:2em;display:inline-block"></div>var&nbsp;dataEnabled&nbsp;=&nbsp;false;
<a name="line931"></a><div class="linenumber">931</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line932"></a><div class="linenumber">932</div><div style="width:2em;display:inline-block"></div>var&nbsp;serverPath&nbsp;=&nbsp;null;&nbsp;//&nbsp;this&nbsp;was&nbsp;null,&nbsp;but&nbsp;that&nbsp;was&nbsp;generating&nbsp;an&nbsp;error.
<a name="line933"></a><div class="linenumber">933</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line934"></a><div class="linenumber">934</div><div style="width:2em;display:inline-block"></div>var&nbsp;roomOccupantListener&nbsp;=&nbsp;null;
<a name="line935"></a><div class="linenumber">935</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line936"></a><div class="linenumber">936</div><div style="width:2em;display:inline-block"></div>var&nbsp;onDataChannelOpen&nbsp;=&nbsp;null;
<a name="line937"></a><div class="linenumber">937</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line938"></a><div class="linenumber">938</div><div style="width:2em;display:inline-block"></div>var&nbsp;onDataChannelClose&nbsp;=&nbsp;null;
<a name="line939"></a><div class="linenumber">939</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line940"></a><div class="linenumber">940</div><div style="width:2em;display:inline-block"></div>var&nbsp;lastLoggedInList&nbsp;=&nbsp;{};
<a name="line941"></a><div class="linenumber">941</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line942"></a><div class="linenumber">942</div><div style="width:2em;display:inline-block"></div>var&nbsp;receivePeer&nbsp;=&nbsp;{msgTypes:&nbsp;{}};
<a name="line943"></a><div class="linenumber">943</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line944"></a><div class="linenumber">944</div><div style="width:2em;display:inline-block"></div>var&nbsp;receiveServerCB&nbsp;=&nbsp;null;
<a name="line945"></a><div class="linenumber">945</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line946"></a><div class="linenumber">946</div><div style="width:2em;display:inline-block"></div>//&nbsp;dummy&nbsp;placeholder&nbsp;for&nbsp;when&nbsp;we&nbsp;aren't&nbsp;connected
<a name="line947"></a><div class="linenumber">947</div><div style="width:2em;display:inline-block"></div>var&nbsp;updateConfigurationInfo&nbsp;=&nbsp;function()&nbsp;{&nbsp;};
<a name="line948"></a><div class="linenumber">948</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line949"></a><div class="linenumber">949</div><div style="width:2em;display:inline-block"></div>//
<a name="line950"></a><div class="linenumber">950</div><div style="width:2em;display:inline-block"></div>//
<a name="line951"></a><div class="linenumber">951</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;peerConns&nbsp;is&nbsp;a&nbsp;map&nbsp;from&nbsp;caller&nbsp;names&nbsp;to&nbsp;the&nbsp;below&nbsp;object&nbsp;structure
<a name="line952"></a><div class="linenumber">952</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;startedAV:&nbsp;boolean,&nbsp;&nbsp;--&nbsp;true&nbsp;if&nbsp;we&nbsp;have&nbsp;traded&nbsp;audio/video&nbsp;streams
<a name="line953"></a><div class="linenumber">953</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataChannelS:&nbsp;RTPDataChannel&nbsp;for&nbsp;outgoing&nbsp;messages&nbsp;if&nbsp;present
<a name="line954"></a><div class="linenumber">954</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataChannelR:&nbsp;RTPDataChannel&nbsp;for&nbsp;incoming&nbsp;messages&nbsp;if&nbsp;present
<a name="line955"></a><div class="linenumber">955</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dataChannelReady:&nbsp;true&nbsp;if&nbsp;the&nbsp;data&nbsp;channel&nbsp;can&nbsp;be&nbsp;used&nbsp;for&nbsp;sending&nbsp;yet
<a name="line956"></a><div class="linenumber">956</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connectTime:&nbsp;timestamp&nbsp;when&nbsp;the&nbsp;connection&nbsp;was&nbsp;started
<a name="line957"></a><div class="linenumber">957</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sharingAudio:&nbsp;true&nbsp;if&nbsp;audio&nbsp;is&nbsp;being&nbsp;shared
<a name="line958"></a><div class="linenumber">958</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sharingVideo:&nbsp;true&nbsp;if&nbsp;video&nbsp;is&nbsp;being&nbsp;shared
<a name="line959"></a><div class="linenumber">959</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cancelled:&nbsp;temporarily&nbsp;true&nbsp;if&nbsp;a&nbsp;connection&nbsp;was&nbsp;cancelled&nbsp;by&nbsp;the&nbsp;peer&nbsp;asking&nbsp;to&nbsp;initiate&nbsp;it
<a name="line960"></a><div class="linenumber">960</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;candidatesToSend:&nbsp;SDP&nbsp;candidates&nbsp;temporarily&nbsp;queued
<a name="line961"></a><div class="linenumber">961</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;streamsAddedAcks:&nbsp;ack&nbsp;callbacks&nbsp;waiting&nbsp;for&nbsp;stream&nbsp;received&nbsp;messages
<a name="line962"></a><div class="linenumber">962</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pc:&nbsp;RTCPeerConnection
<a name="line963"></a><div class="linenumber">963</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mediaStream:&nbsp;mediaStream
<a name="line964"></a><div class="linenumber">964</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;callSuccessCB(string)&nbsp;-&nbsp;see&nbsp;the&nbsp;easyrtc.call&nbsp;documentation.
<a name="line965"></a><div class="linenumber">965</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;callFailureCB(errorCode,&nbsp;string)&nbsp;-&nbsp;see&nbsp;the&nbsp;easyrtc.call&nbsp;documentation.
<a name="line966"></a><div class="linenumber">966</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;wasAcceptedCB(boolean,string)&nbsp;-&nbsp;see&nbsp;the&nbsp;easyrtc.call&nbsp;documentation.
<a name="line967"></a><div class="linenumber">967</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line968"></a><div class="linenumber">968</div><div style="width:2em;display:inline-block"></div>//
<a name="line969"></a><div class="linenumber">969</div><div style="width:2em;display:inline-block"></div>var&nbsp;peerConns&nbsp;=&nbsp;{};
<a name="line970"></a><div class="linenumber">970</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line971"></a><div class="linenumber">971</div><div style="width:2em;display:inline-block"></div>//
<a name="line972"></a><div class="linenumber">972</div><div style="width:2em;display:inline-block"></div>//&nbsp;a&nbsp;map&nbsp;keeping&nbsp;track&nbsp;of&nbsp;whom&nbsp;we've&nbsp;requested&nbsp;a&nbsp;call&nbsp;with&nbsp;so&nbsp;we&nbsp;don't&nbsp;try&nbsp;to
<a name="line973"></a><div class="linenumber">973</div><div style="width:2em;display:inline-block"></div>//&nbsp;call&nbsp;them&nbsp;a&nbsp;second&nbsp;time&nbsp;before&nbsp;they've&nbsp;responded.
<a name="line974"></a><div class="linenumber">974</div><div style="width:2em;display:inline-block"></div>//
<a name="line975"></a><div class="linenumber">975</div><div style="width:2em;display:inline-block"></div>var&nbsp;acceptancePending&nbsp;=&nbsp;{};
<a name="line976"></a><div class="linenumber">976</div>
<a name="line977"></a><div class="linenumber">977</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line978"></a><div class="linenumber">978</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;caller
<a name="line979"></a><div class="linenumber">979</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;helper
<a name="line980"></a><div class="linenumber">980</div><div style="width:2em;display:inline-block"></div>*/
<a name="line981"></a><div class="linenumber">981</div><div style="width:2em;display:inline-block"></div>this.acceptCheck&nbsp;=&nbsp;function(caller,&nbsp;helper)&nbsp;{
<a name="line982"></a><div class="linenumber">982</div><div style="width:4em;display:inline-block"></div>helper(true);
<a name="line983"></a><div class="linenumber">983</div><div style="width:2em;display:inline-block"></div>};
<a name="line984"></a><div class="linenumber">984</div>
<a name="line985"></a><div class="linenumber">985</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line986"></a><div class="linenumber">986</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;easyrtcid
<a name="line987"></a><div class="linenumber">987</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{HTMLMediaStream}&nbsp;stream
<a name="line988"></a><div class="linenumber">988</div><div style="width:2em;display:inline-block"></div>*/
<a name="line989"></a><div class="linenumber">989</div><div style="width:2em;display:inline-block"></div>this.streamAcceptor&nbsp;=&nbsp;function(easyrtcid,&nbsp;stream)&nbsp;{
<a name="line990"></a><div class="linenumber">990</div><div style="width:2em;display:inline-block"></div>};
<a name="line991"></a><div class="linenumber">991</div>
<a name="line992"></a><div class="linenumber">992</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line993"></a><div class="linenumber">993</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;easyrtcid
<a name="line994"></a><div class="linenumber">994</div><div style="width:2em;display:inline-block"></div>*/
<a name="line995"></a><div class="linenumber">995</div><div style="width:2em;display:inline-block"></div>this.onStreamClosed&nbsp;=&nbsp;function(easyrtcid)&nbsp;{
<a name="line996"></a><div class="linenumber">996</div><div style="width:2em;display:inline-block"></div>};
<a name="line997"></a><div class="linenumber">997</div>
<a name="line998"></a><div class="linenumber">998</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line999"></a><div class="linenumber">999</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;easyrtcid
<a name="line1000"></a><div class="linenumber">1000</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1001"></a><div class="linenumber">1001</div><div style="width:2em;display:inline-block"></div>this.callCancelled&nbsp;=&nbsp;function(easyrtcid)&nbsp;{
<a name="line1002"></a><div class="linenumber">1002</div><div style="width:2em;display:inline-block"></div>};
<a name="line1003"></a><div class="linenumber">1003</div>
<a name="line1004"></a><div class="linenumber">1004</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1005"></a><div class="linenumber">1005</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;gets&nbsp;the&nbsp;raw&nbsp;RTCPeerConnection&nbsp;for&nbsp;a&nbsp;given&nbsp;easyrtcid
<a name="line1006"></a><div class="linenumber">1006</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid
<a name="line1007"></a><div class="linenumber">1007</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{RTCPeerConnection}&nbsp;for&nbsp;that&nbsp;easyrtcid,&nbsp;or&nbsp;null&nbsp;if&nbsp;no&nbsp;connection&nbsp;exists
<a name="line1008"></a><div class="linenumber">1008</div><div style="width:2em;display:inline-block"></div>*&nbsp;Submitted&nbsp;by&nbsp;Fabian&nbsp;Bernhard.
<a name="line1009"></a><div class="linenumber">1009</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1010"></a><div class="linenumber">1010</div><div style="width:2em;display:inline-block"></div>this.getPeerConnectionByUserId&nbsp;=&nbsp;function(userId)&nbsp;{
<a name="line1011"></a><div class="linenumber">1011</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns&nbsp;&amp;&amp;&nbsp;peerConns[userId])&nbsp;{
<a name="line1012"></a><div class="linenumber">1012</div><div style="width:6em;display:inline-block"></div>return&nbsp;peerConns[userId].pc;
<a name="line1013"></a><div class="linenumber">1013</div><div style="width:4em;display:inline-block"></div>}
<a name="line1014"></a><div class="linenumber">1014</div><div style="width:4em;display:inline-block"></div>return&nbsp;null;
<a name="line1015"></a><div class="linenumber">1015</div><div style="width:2em;display:inline-block"></div>};
<a name="line1016"></a><div class="linenumber">1016</div>
<a name="line1017"></a><div class="linenumber">1017</div>
<a name="line1018"></a><div class="linenumber">1018</div><div style="width:2em;display:inline-block"></div>var&nbsp;chromeStatsFilter&nbsp;=&nbsp;[
<a name="line1019"></a><div class="linenumber">1019</div><div style="width:4em;display:inline-block"></div>{
<a name="line1020"></a><div class="linenumber">1020</div><div style="width:6em;display:inline-block"></div>"googTransmitBitrate":&nbsp;"transmitBitRate",
<a name="line1021"></a><div class="linenumber">1021</div><div style="width:6em;display:inline-block"></div>"googActualEncBitrate":&nbsp;"encodeRate",
<a name="line1022"></a><div class="linenumber">1022</div><div style="width:6em;display:inline-block"></div>"googAvailableSendBandwidth":&nbsp;"availableSendRate"
<a name="line1023"></a><div class="linenumber">1023</div><div style="width:4em;display:inline-block"></div>},
<a name="line1024"></a><div class="linenumber">1024</div><div style="width:4em;display:inline-block"></div>{
<a name="line1025"></a><div class="linenumber">1025</div><div style="width:6em;display:inline-block"></div>"googCodecName":&nbsp;"audioCodec",
<a name="line1026"></a><div class="linenumber">1026</div><div style="width:6em;display:inline-block"></div>"googTypingNoiseState":&nbsp;"typingNoise",
<a name="line1027"></a><div class="linenumber">1027</div><div style="width:6em;display:inline-block"></div>"packetsSent":&nbsp;"audioPacketsSent",
<a name="line1028"></a><div class="linenumber">1028</div><div style="width:6em;display:inline-block"></div>"bytesSent":&nbsp;"audioBytesSent"
<a name="line1029"></a><div class="linenumber">1029</div><div style="width:4em;display:inline-block"></div>},
<a name="line1030"></a><div class="linenumber">1030</div><div style="width:4em;display:inline-block"></div>{
<a name="line1031"></a><div class="linenumber">1031</div><div style="width:6em;display:inline-block"></div>"googCodecName":&nbsp;"videoCodec",
<a name="line1032"></a><div class="linenumber">1032</div><div style="width:6em;display:inline-block"></div>"googFrameRateSent":&nbsp;"outFrameRate",
<a name="line1033"></a><div class="linenumber">1033</div><div style="width:6em;display:inline-block"></div>"packetsSent":&nbsp;"videoPacketsSent",
<a name="line1034"></a><div class="linenumber">1034</div><div style="width:6em;display:inline-block"></div>"bytesSent":&nbsp;"videoBytesSent"
<a name="line1035"></a><div class="linenumber">1035</div><div style="width:4em;display:inline-block"></div>},
<a name="line1036"></a><div class="linenumber">1036</div><div style="width:4em;display:inline-block"></div>{
<a name="line1037"></a><div class="linenumber">1037</div><div style="width:6em;display:inline-block"></div>"packetsLost":&nbsp;"videoPacketsLost",
<a name="line1038"></a><div class="linenumber">1038</div><div style="width:6em;display:inline-block"></div>"packetsReceived":&nbsp;"videoPacketsReceived",
<a name="line1039"></a><div class="linenumber">1039</div><div style="width:6em;display:inline-block"></div>"bytesReceived":&nbsp;"videoBytesReceived",
<a name="line1040"></a><div class="linenumber">1040</div><div style="width:6em;display:inline-block"></div>"googFrameRateOutput":&nbsp;"frameRateOut"
<a name="line1041"></a><div class="linenumber">1041</div><div style="width:4em;display:inline-block"></div>},
<a name="line1042"></a><div class="linenumber">1042</div><div style="width:4em;display:inline-block"></div>{
<a name="line1043"></a><div class="linenumber">1043</div><div style="width:6em;display:inline-block"></div>"packetsLost":&nbsp;"audioPacketsLost",
<a name="line1044"></a><div class="linenumber">1044</div><div style="width:6em;display:inline-block"></div>"packetsReceived":&nbsp;"audioPacketsReceived",
<a name="line1045"></a><div class="linenumber">1045</div><div style="width:6em;display:inline-block"></div>"bytesReceived":&nbsp;"audioBytesReceived",
<a name="line1046"></a><div class="linenumber">1046</div><div style="width:6em;display:inline-block"></div>"audioOutputLevel":&nbsp;"audioOutputLevel"
<a name="line1047"></a><div class="linenumber">1047</div><div style="width:4em;display:inline-block"></div>},
<a name="line1048"></a><div class="linenumber">1048</div><div style="width:4em;display:inline-block"></div>{
<a name="line1049"></a><div class="linenumber">1049</div><div style="width:6em;display:inline-block"></div>"googRemoteAddress":&nbsp;"remoteAddress",
<a name="line1050"></a><div class="linenumber">1050</div><div style="width:6em;display:inline-block"></div>"googActiveConnection":&nbsp;"activeConnection"
<a name="line1051"></a><div class="linenumber">1051</div><div style="width:4em;display:inline-block"></div>},
<a name="line1052"></a><div class="linenumber">1052</div><div style="width:4em;display:inline-block"></div>{
<a name="line1053"></a><div class="linenumber">1053</div><div style="width:6em;display:inline-block"></div>"audioInputLevel":&nbsp;"audioInputLevel"
<a name="line1054"></a><div class="linenumber">1054</div><div style="width:4em;display:inline-block"></div>}
<a name="line1055"></a><div class="linenumber">1055</div><div style="width:2em;display:inline-block"></div>];
<a name="line1056"></a><div class="linenumber">1056</div>
<a name="line1057"></a><div class="linenumber">1057</div><div style="width:2em;display:inline-block"></div>var&nbsp;firefoxStatsFilter&nbsp;=&nbsp;{
<a name="line1058"></a><div class="linenumber">1058</div><div style="width:4em;display:inline-block"></div>"outboundrtp_audio.bytesSent":&nbsp;"audioBytesSent",
<a name="line1059"></a><div class="linenumber">1059</div><div style="width:4em;display:inline-block"></div>"outboundrtp_video.bytesSent":&nbsp;"videoBytesSent",
<a name="line1060"></a><div class="linenumber">1060</div><div style="width:4em;display:inline-block"></div>"inboundrtp_video.bytesReceived":&nbsp;"videoBytesReceived",
<a name="line1061"></a><div class="linenumber">1061</div><div style="width:4em;display:inline-block"></div>"inboundrtp_audio.bytesReceived":&nbsp;"audioBytesReceived",
<a name="line1062"></a><div class="linenumber">1062</div><div style="width:4em;display:inline-block"></div>"outboundrtp_audio.packetsSent":&nbsp;"audioPacketsSent",
<a name="line1063"></a><div class="linenumber">1063</div><div style="width:4em;display:inline-block"></div>"outboundrtp_video.packetsSent":&nbsp;"videoPacketsSent",
<a name="line1064"></a><div class="linenumber">1064</div><div style="width:4em;display:inline-block"></div>"inboundrtp_video.packetsReceived":&nbsp;"videoPacketsReceived",
<a name="line1065"></a><div class="linenumber">1065</div><div style="width:4em;display:inline-block"></div>"inboundrtp_audio.packetsReceived":&nbsp;"audioPacketsReceived",
<a name="line1066"></a><div class="linenumber">1066</div><div style="width:4em;display:inline-block"></div>"inboundrtp_video.packetsLost":&nbsp;"videoPacketsLost",
<a name="line1067"></a><div class="linenumber">1067</div><div style="width:4em;display:inline-block"></div>"inboundrtp_audio.packetsLost":&nbsp;"audioPacketsLost",
<a name="line1068"></a><div class="linenumber">1068</div><div style="width:4em;display:inline-block"></div>"firefoxRemoteAddress":&nbsp;"remoteAddress"
<a name="line1069"></a><div class="linenumber">1069</div><div style="width:2em;display:inline-block"></div>};
<a name="line1070"></a><div class="linenumber">1070</div>
<a name="line1071"></a><div class="linenumber">1071</div><div style="width:2em;display:inline-block"></div>var&nbsp;standardStatsFilter&nbsp;=&nbsp;adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line1072"></a><div class="linenumber">1072</div><div style="width:8em;display:inline-block"></div>adapter.browserDetails.browser&nbsp;===&nbsp;"firefox"&nbsp;?&nbsp;firefoxStatsFilter&nbsp;:&nbsp;chromeStatsFilter;
<a name="line1073"></a><div class="linenumber">1073</div>
<a name="line1074"></a><div class="linenumber">1074</div><div style="width:2em;display:inline-block"></div>function&nbsp;getFirefoxPeerStatistics(peerId,&nbsp;callback,&nbsp;filter)&nbsp;{
<a name="line1075"></a><div class="linenumber">1075</div>
<a name="line1076"></a><div class="linenumber">1076</div>
<a name="line1077"></a><div class="linenumber">1077</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[peerId])&nbsp;{
<a name="line1078"></a><div class="linenumber">1078</div><div style="width:6em;display:inline-block"></div>callback(peerId,&nbsp;{"connected":&nbsp;false});
<a name="line1079"></a><div class="linenumber">1079</div><div style="width:4em;display:inline-block"></div>}
<a name="line1080"></a><div class="linenumber">1080</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(peerConns[peerId].pc.getStats)&nbsp;{
<a name="line1081"></a><div class="linenumber">1081</div><div style="width:6em;display:inline-block"></div>peerConns[peerId].pc.getStats(null,&nbsp;function(stats)&nbsp;{
<a name="line1082"></a><div class="linenumber">1082</div><div style="width:8em;display:inline-block"></div>var&nbsp;items&nbsp;=&nbsp;{};
<a name="line1083"></a><div class="linenumber">1083</div><div style="width:8em;display:inline-block"></div>var&nbsp;candidates&nbsp;=&nbsp;{};
<a name="line1084"></a><div class="linenumber">1084</div><div style="width:8em;display:inline-block"></div>var&nbsp;activeId&nbsp;=&nbsp;null;
<a name="line1085"></a><div class="linenumber">1085</div><div style="width:8em;display:inline-block"></div>var&nbsp;srcKey;
<a name="line1086"></a><div class="linenumber">1086</div><div style="width:8em;display:inline-block"></div>//
<a name="line1087"></a><div class="linenumber">1087</div><div style="width:8em;display:inline-block"></div>//&nbsp;the&nbsp;stats&nbsp;objects&nbsp;has&nbsp;a&nbsp;group&nbsp;of&nbsp;entries.&nbsp;Each&nbsp;entry&nbsp;is&nbsp;either&nbsp;an&nbsp;rtcp,&nbsp;rtp&nbsp;entry
<a name="line1088"></a><div class="linenumber">1088</div><div style="width:8em;display:inline-block"></div>//&nbsp;or&nbsp;a&nbsp;candidate&nbsp;entry.
<a name="line1089"></a><div class="linenumber">1089</div><div style="width:8em;display:inline-block"></div>//
<a name="line1090"></a><div class="linenumber">1090</div><div style="width:8em;display:inline-block"></div>if&nbsp;(stats)&nbsp;{
<a name="line1091"></a><div class="linenumber">1091</div><div style="width:10em;display:inline-block"></div>stats.forEach(function(entry)&nbsp;{
<a name="line1092"></a><div class="linenumber">1092</div><div style="width:12em;display:inline-block"></div>var&nbsp;majorKey;
<a name="line1093"></a><div class="linenumber">1093</div><div style="width:12em;display:inline-block"></div>var&nbsp;subKey;
<a name="line1094"></a><div class="linenumber">1094</div><div style="width:12em;display:inline-block"></div>if&nbsp;(entry.type.match(/boundrtp/))&nbsp;{
<a name="line1095"></a><div class="linenumber">1095</div><div style="width:14em;display:inline-block"></div>if&nbsp;(entry.id.match(/audio/))&nbsp;{
<a name="line1096"></a><div class="linenumber">1096</div><div style="width:16em;display:inline-block"></div>majorKey&nbsp;=&nbsp;entry.type&nbsp;+&nbsp;"_audio";
<a name="line1097"></a><div class="linenumber">1097</div><div style="width:14em;display:inline-block"></div>}
<a name="line1098"></a><div class="linenumber">1098</div><div style="width:14em;display:inline-block"></div>else&nbsp;if&nbsp;(entry.id.match(/video/))&nbsp;{
<a name="line1099"></a><div class="linenumber">1099</div><div style="width:16em;display:inline-block"></div>majorKey&nbsp;=&nbsp;entry.type&nbsp;+&nbsp;"_video";
<a name="line1100"></a><div class="linenumber">1100</div><div style="width:14em;display:inline-block"></div>}
<a name="line1101"></a><div class="linenumber">1101</div><div style="width:14em;display:inline-block"></div>else&nbsp;{
<a name="line1102"></a><div class="linenumber">1102</div><div style="width:16em;display:inline-block"></div>return;
<a name="line1103"></a><div class="linenumber">1103</div><div style="width:14em;display:inline-block"></div>}
<a name="line1104"></a><div class="linenumber">1104</div><div style="width:14em;display:inline-block"></div>for&nbsp;(subKey&nbsp;in&nbsp;entry)&nbsp;{
<a name="line1105"></a><div class="linenumber">1105</div><div style="width:16em;display:inline-block"></div>if&nbsp;(entry.hasOwnProperty(subKey))&nbsp;{
<a name="line1106"></a><div class="linenumber">1106</div><div style="width:18em;display:inline-block"></div>items[majorKey&nbsp;+&nbsp;"."&nbsp;+&nbsp;subKey]&nbsp;=&nbsp;entry[subKey];
<a name="line1107"></a><div class="linenumber">1107</div><div style="width:16em;display:inline-block"></div>}
<a name="line1108"></a><div class="linenumber">1108</div><div style="width:14em;display:inline-block"></div>}
<a name="line1109"></a><div class="linenumber">1109</div><div style="width:12em;display:inline-block"></div>}
<a name="line1110"></a><div class="linenumber">1110</div><div style="width:12em;display:inline-block"></div>else&nbsp;{
<a name="line1111"></a><div class="linenumber">1111</div><div style="width:14em;display:inline-block"></div>if(&nbsp;entry.hasOwnProperty("ipAddress")&nbsp;&amp;&amp;&nbsp;entry.id)&nbsp;{
<a name="line1112"></a><div class="linenumber">1112</div><div style="width:16em;display:inline-block"></div>candidates[entry.id]&nbsp;=&nbsp;entry.ipAddress&nbsp;+&nbsp;":"&nbsp;+
<a name="line1113"></a><div class="linenumber">1113</div><div style="width:19em;display:inline-block"></div>entry.portNumber;
<a name="line1114"></a><div class="linenumber">1114</div><div style="width:14em;display:inline-block"></div>}
<a name="line1115"></a><div class="linenumber">1115</div><div style="width:14em;display:inline-block"></div>else&nbsp;if(&nbsp;entry.hasOwnProperty("selected")&nbsp;&amp;&amp;
<a name="line1116"></a><div class="linenumber">1116</div><div style="width:18em;display:inline-block"></div>entry.hasOwnProperty("remoteCandidateId")&nbsp;&amp;&amp;
<a name="line1117"></a><div class="linenumber">1117</div><div style="width:18em;display:inline-block"></div>entry.selected&nbsp;)&nbsp;{
<a name="line1118"></a><div class="linenumber">1118</div><div style="width:16em;display:inline-block"></div>activeId&nbsp;=&nbsp;&nbsp;entry.remoteCandidateId;
<a name="line1119"></a><div class="linenumber">1119</div><div style="width:14em;display:inline-block"></div>}
<a name="line1120"></a><div class="linenumber">1120</div><div style="width:12em;display:inline-block"></div>}
<a name="line1121"></a><div class="linenumber">1121</div><div style="width:10em;display:inline-block"></div>});
<a name="line1122"></a><div class="linenumber">1122</div><div style="width:8em;display:inline-block"></div>}
<a name="line1123"></a><div class="linenumber">1123</div>
<a name="line1124"></a><div class="linenumber">1124</div><div style="width:8em;display:inline-block"></div>if(&nbsp;activeId&nbsp;)&nbsp;{
<a name="line1125"></a><div class="linenumber">1125</div><div style="width:10em;display:inline-block"></div>items["firefoxRemoteAddress"]&nbsp;=&nbsp;candidates[activeId];
<a name="line1126"></a><div class="linenumber">1126</div><div style="width:8em;display:inline-block"></div>}
<a name="line1127"></a><div class="linenumber">1127</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!filter)&nbsp;{
<a name="line1128"></a><div class="linenumber">1128</div><div style="width:10em;display:inline-block"></div>callback(peerId,&nbsp;items);
<a name="line1129"></a><div class="linenumber">1129</div><div style="width:8em;display:inline-block"></div>}
<a name="line1130"></a><div class="linenumber">1130</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line1131"></a><div class="linenumber">1131</div><div style="width:10em;display:inline-block"></div>var&nbsp;filteredItems&nbsp;=&nbsp;{};
<a name="line1132"></a><div class="linenumber">1132</div><div style="width:10em;display:inline-block"></div>for&nbsp;(srcKey&nbsp;in&nbsp;filter)&nbsp;{
<a name="line1133"></a><div class="linenumber">1133</div><div style="width:12em;display:inline-block"></div>if&nbsp;(filter.hasOwnProperty(srcKey)&nbsp;&amp;&amp;&nbsp;items.hasOwnProperty(srcKey))&nbsp;{
<a name="line1134"></a><div class="linenumber">1134</div><div style="width:14em;display:inline-block"></div>filteredItems[&nbsp;filter[srcKey]]&nbsp;=&nbsp;items[srcKey];
<a name="line1135"></a><div class="linenumber">1135</div><div style="width:12em;display:inline-block"></div>}
<a name="line1136"></a><div class="linenumber">1136</div><div style="width:10em;display:inline-block"></div>}
<a name="line1137"></a><div class="linenumber">1137</div><div style="width:10em;display:inline-block"></div>callback(peerId,&nbsp;filteredItems);
<a name="line1138"></a><div class="linenumber">1138</div><div style="width:8em;display:inline-block"></div>}
<a name="line1139"></a><div class="linenumber">1139</div><div style="width:6em;display:inline-block"></div>},
<a name="line1140"></a><div class="linenumber">1140</div><div style="width:10em;display:inline-block"></div>function(error)&nbsp;{
<a name="line1141"></a><div class="linenumber">1141</div><div style="width:12em;display:inline-block"></div>logDebug("unable&nbsp;to&nbsp;get&nbsp;statistics");
<a name="line1142"></a><div class="linenumber">1142</div><div style="width:10em;display:inline-block"></div>});
<a name="line1143"></a><div class="linenumber">1143</div><div style="width:4em;display:inline-block"></div>}
<a name="line1144"></a><div class="linenumber">1144</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1145"></a><div class="linenumber">1145</div><div style="width:6em;display:inline-block"></div>callback(peerId,&nbsp;{"statistics":&nbsp;self.getConstantString("statsNotSupported")});
<a name="line1146"></a><div class="linenumber">1146</div><div style="width:4em;display:inline-block"></div>}
<a name="line1147"></a><div class="linenumber">1147</div><div style="width:2em;display:inline-block"></div>}
<a name="line1148"></a><div class="linenumber">1148</div>
<a name="line1149"></a><div class="linenumber">1149</div><div style="width:2em;display:inline-block"></div>function&nbsp;getChromePeerStatistics(peerId,&nbsp;callback,&nbsp;filter)&nbsp;{
<a name="line1150"></a><div class="linenumber">1150</div>
<a name="line1151"></a><div class="linenumber">1151</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[peerId])&nbsp;{
<a name="line1152"></a><div class="linenumber">1152</div><div style="width:6em;display:inline-block"></div>callback(peerId,&nbsp;{"connected":&nbsp;false});
<a name="line1153"></a><div class="linenumber">1153</div><div style="width:4em;display:inline-block"></div>}
<a name="line1154"></a><div class="linenumber">1154</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(peerConns[peerId].pc.getStats)&nbsp;{
<a name="line1155"></a><div class="linenumber">1155</div>
<a name="line1156"></a><div class="linenumber">1156</div><div style="width:6em;display:inline-block"></div>peerConns[peerId].pc.getStats(function(stats)&nbsp;{
<a name="line1157"></a><div class="linenumber">1157</div>
<a name="line1158"></a><div class="linenumber">1158</div><div style="width:8em;display:inline-block"></div>var&nbsp;localStats&nbsp;=&nbsp;{};
<a name="line1159"></a><div class="linenumber">1159</div><div style="width:8em;display:inline-block"></div>var&nbsp;part,&nbsp;parts&nbsp;=&nbsp;stats.result();
<a name="line1160"></a><div class="linenumber">1160</div><div style="width:8em;display:inline-block"></div>var&nbsp;i,&nbsp;j;
<a name="line1161"></a><div class="linenumber">1161</div><div style="width:8em;display:inline-block"></div>var&nbsp;itemKeys;
<a name="line1162"></a><div class="linenumber">1162</div><div style="width:8em;display:inline-block"></div>var&nbsp;itemKey;
<a name="line1163"></a><div class="linenumber">1163</div><div style="width:8em;display:inline-block"></div>var&nbsp;names;
<a name="line1164"></a><div class="linenumber">1164</div><div style="width:8em;display:inline-block"></div>var&nbsp;userKey;
<a name="line1165"></a><div class="linenumber">1165</div><div style="width:8em;display:inline-block"></div>var&nbsp;partNames&nbsp;=&nbsp;[];
<a name="line1166"></a><div class="linenumber">1166</div><div style="width:8em;display:inline-block"></div>var&nbsp;partList;
<a name="line1167"></a><div class="linenumber">1167</div><div style="width:8em;display:inline-block"></div>var&nbsp;bestBytes&nbsp;=&nbsp;0;
<a name="line1168"></a><div class="linenumber">1168</div><div style="width:8em;display:inline-block"></div>var&nbsp;bestI;
<a name="line1169"></a><div class="linenumber">1169</div><div style="width:8em;display:inline-block"></div>var&nbsp;turnAddress&nbsp;=&nbsp;null;
<a name="line1170"></a><div class="linenumber">1170</div><div style="width:8em;display:inline-block"></div>var&nbsp;hasActive,&nbsp;curReceived;
<a name="line1171"></a><div class="linenumber">1171</div><div style="width:8em;display:inline-block"></div>var&nbsp;localAddress,&nbsp;remoteAddress;
<a name="line1172"></a><div class="linenumber">1172</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!filter)&nbsp;{
<a name="line1173"></a><div class="linenumber">1173</div><div style="width:10em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;parts.length;&nbsp;i++)&nbsp;{
<a name="line1174"></a><div class="linenumber">1174</div><div style="width:12em;display:inline-block"></div>names&nbsp;=&nbsp;parts[i].names();
<a name="line1175"></a><div class="linenumber">1175</div><div style="width:12em;display:inline-block"></div>for&nbsp;(j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;names.length;&nbsp;j++)&nbsp;{
<a name="line1176"></a><div class="linenumber">1176</div><div style="width:14em;display:inline-block"></div>itemKey&nbsp;=&nbsp;names[j];
<a name="line1177"></a><div class="linenumber">1177</div><div style="width:14em;display:inline-block"></div>localStats[parts[i].id&nbsp;+&nbsp;"."&nbsp;+&nbsp;itemKey]&nbsp;=&nbsp;parts[i].stat(itemKey);
<a name="line1178"></a><div class="linenumber">1178</div><div style="width:12em;display:inline-block"></div>}
<a name="line1179"></a><div class="linenumber">1179</div><div style="width:10em;display:inline-block"></div>}
<a name="line1180"></a><div class="linenumber">1180</div><div style="width:8em;display:inline-block"></div>}
<a name="line1181"></a><div class="linenumber">1181</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line1182"></a><div class="linenumber">1182</div><div style="width:10em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;parts.length;&nbsp;i++)&nbsp;{
<a name="line1183"></a><div class="linenumber">1183</div><div style="width:12em;display:inline-block"></div>partNames[i]&nbsp;=&nbsp;{};
<a name="line1184"></a><div class="linenumber">1184</div><div style="width:12em;display:inline-block"></div>//
<a name="line1185"></a><div class="linenumber">1185</div><div style="width:12em;display:inline-block"></div>//&nbsp;convert&nbsp;the&nbsp;names&nbsp;into&nbsp;a&nbsp;dictionary
<a name="line1186"></a><div class="linenumber">1186</div><div style="width:12em;display:inline-block"></div>//
<a name="line1187"></a><div class="linenumber">1187</div><div style="width:12em;display:inline-block"></div>names&nbsp;=&nbsp;parts[i].names();
<a name="line1188"></a><div class="linenumber">1188</div><div style="width:12em;display:inline-block"></div>for&nbsp;(j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;names.length;&nbsp;j++)&nbsp;{
<a name="line1189"></a><div class="linenumber">1189</div><div style="width:14em;display:inline-block"></div>partNames[i][names[j]]&nbsp;=&nbsp;true;
<a name="line1190"></a><div class="linenumber">1190</div><div style="width:12em;display:inline-block"></div>}
<a name="line1191"></a><div class="linenumber">1191</div>
<a name="line1192"></a><div class="linenumber">1192</div><div style="width:12em;display:inline-block"></div>//
<a name="line1193"></a><div class="linenumber">1193</div><div style="width:12em;display:inline-block"></div>//&nbsp;a&nbsp;chrome-firefox&nbsp;connection&nbsp;results&nbsp;in&nbsp;several&nbsp;activeConnections.
<a name="line1194"></a><div class="linenumber">1194</div><div style="width:12em;display:inline-block"></div>//&nbsp;we&nbsp;only&nbsp;want&nbsp;one,&nbsp;so&nbsp;we&nbsp;look&nbsp;for&nbsp;the&nbsp;one&nbsp;with&nbsp;the&nbsp;most&nbsp;data&nbsp;being&nbsp;received&nbsp;on&nbsp;it.
<a name="line1195"></a><div class="linenumber">1195</div><div style="width:12em;display:inline-block"></div>//
<a name="line1196"></a><div class="linenumber">1196</div><div style="width:12em;display:inline-block"></div>if&nbsp;(partNames[i].googRemoteAddress&nbsp;&amp;&amp;&nbsp;partNames[i].googActiveConnection)&nbsp;{
<a name="line1197"></a><div class="linenumber">1197</div><div style="width:14em;display:inline-block"></div>hasActive&nbsp;=&nbsp;parts[i].stat("googActiveConnection");
<a name="line1198"></a><div class="linenumber">1198</div><div style="width:14em;display:inline-block"></div>if&nbsp;(hasActive&nbsp;===&nbsp;true&nbsp;||&nbsp;hasActive&nbsp;===&nbsp;"true")&nbsp;{
<a name="line1199"></a><div class="linenumber">1199</div><div style="width:16em;display:inline-block"></div>curReceived&nbsp;=&nbsp;parseInt(parts[i].stat("bytesReceived"))&nbsp;+
<a name="line1200"></a><div class="linenumber">1200</div><div style="width:20em;display:inline-block"></div>parseInt(parts[i].stat("bytesSent"));
<a name="line1201"></a><div class="linenumber">1201</div><div style="width:16em;display:inline-block"></div>if&nbsp;(curReceived&nbsp;&gt;&nbsp;bestBytes)&nbsp;{
<a name="line1202"></a><div class="linenumber">1202</div><div style="width:18em;display:inline-block"></div>bestI&nbsp;=&nbsp;i;
<a name="line1203"></a><div class="linenumber">1203</div><div style="width:18em;display:inline-block"></div>bestBytes&nbsp;=&nbsp;curReceived;
<a name="line1204"></a><div class="linenumber">1204</div><div style="width:16em;display:inline-block"></div>}
<a name="line1205"></a><div class="linenumber">1205</div><div style="width:14em;display:inline-block"></div>}
<a name="line1206"></a><div class="linenumber">1206</div><div style="width:12em;display:inline-block"></div>}
<a name="line1207"></a><div class="linenumber">1207</div><div style="width:10em;display:inline-block"></div>}
<a name="line1208"></a><div class="linenumber">1208</div>
<a name="line1209"></a><div class="linenumber">1209</div><div style="width:10em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;parts.length;&nbsp;i++)&nbsp;{
<a name="line1210"></a><div class="linenumber">1210</div><div style="width:12em;display:inline-block"></div>//
<a name="line1211"></a><div class="linenumber">1211</div><div style="width:12em;display:inline-block"></div>//&nbsp;discard&nbsp;info&nbsp;from&nbsp;any&nbsp;inactive&nbsp;connection.
<a name="line1212"></a><div class="linenumber">1212</div><div style="width:12em;display:inline-block"></div>//
<a name="line1213"></a><div class="linenumber">1213</div><div style="width:12em;display:inline-block"></div>if&nbsp;(partNames[i].googActiveConnection)&nbsp;{
<a name="line1214"></a><div class="linenumber">1214</div><div style="width:14em;display:inline-block"></div>if&nbsp;(i&nbsp;!==&nbsp;bestI)&nbsp;{
<a name="line1215"></a><div class="linenumber">1215</div><div style="width:16em;display:inline-block"></div>partNames[i]&nbsp;=&nbsp;{};
<a name="line1216"></a><div class="linenumber">1216</div><div style="width:14em;display:inline-block"></div>}
<a name="line1217"></a><div class="linenumber">1217</div><div style="width:14em;display:inline-block"></div>else&nbsp;{
<a name="line1218"></a><div class="linenumber">1218</div><div style="width:16em;display:inline-block"></div>localAddress&nbsp;=&nbsp;parts[i].stat("googLocalAddress").split(":")[0];
<a name="line1219"></a><div class="linenumber">1219</div><div style="width:16em;display:inline-block"></div>remoteAddress&nbsp;=&nbsp;parts[i].stat("googRemoteAddress").split(":")[0];
<a name="line1220"></a><div class="linenumber">1220</div><div style="width:16em;display:inline-block"></div>if&nbsp;(self.isTurnServer(localAddress))&nbsp;{
<a name="line1221"></a><div class="linenumber">1221</div><div style="width:18em;display:inline-block"></div>turnAddress&nbsp;=&nbsp;localAddress;
<a name="line1222"></a><div class="linenumber">1222</div><div style="width:16em;display:inline-block"></div>}
<a name="line1223"></a><div class="linenumber">1223</div><div style="width:16em;display:inline-block"></div>else&nbsp;if&nbsp;(self.isTurnServer(remoteAddress))&nbsp;{
<a name="line1224"></a><div class="linenumber">1224</div><div style="width:18em;display:inline-block"></div>turnAddress&nbsp;=&nbsp;remoteAddress;
<a name="line1225"></a><div class="linenumber">1225</div><div style="width:16em;display:inline-block"></div>}
<a name="line1226"></a><div class="linenumber">1226</div><div style="width:14em;display:inline-block"></div>}
<a name="line1227"></a><div class="linenumber">1227</div><div style="width:12em;display:inline-block"></div>}
<a name="line1228"></a><div class="linenumber">1228</div><div style="width:10em;display:inline-block"></div>}
<a name="line1229"></a><div class="linenumber">1229</div>
<a name="line1230"></a><div class="linenumber">1230</div><div style="width:10em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;filter.length;&nbsp;i++)&nbsp;{
<a name="line1231"></a><div class="linenumber">1231</div><div style="width:12em;display:inline-block"></div>itemKeys&nbsp;=&nbsp;filter[i];
<a name="line1232"></a><div class="linenumber">1232</div><div style="width:12em;display:inline-block"></div>partList&nbsp;=&nbsp;[];
<a name="line1233"></a><div class="linenumber">1233</div><div style="width:12em;display:inline-block"></div>part&nbsp;=&nbsp;null;
<a name="line1234"></a><div class="linenumber">1234</div><div style="width:12em;display:inline-block"></div>for&nbsp;(j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;parts.length;&nbsp;j++)&nbsp;{
<a name="line1235"></a><div class="linenumber">1235</div><div style="width:14em;display:inline-block"></div>var&nbsp;fullMatch&nbsp;=&nbsp;true;
<a name="line1236"></a><div class="linenumber">1236</div><div style="width:14em;display:inline-block"></div>for&nbsp;(itemKey&nbsp;in&nbsp;itemKeys)&nbsp;{
<a name="line1237"></a><div class="linenumber">1237</div><div style="width:16em;display:inline-block"></div>if&nbsp;(itemKeys.hasOwnProperty(itemKey)&nbsp;&amp;&amp;&nbsp;!partNames[j][itemKey])&nbsp;{
<a name="line1238"></a><div class="linenumber">1238</div><div style="width:18em;display:inline-block"></div>fullMatch&nbsp;=&nbsp;false;
<a name="line1239"></a><div class="linenumber">1239</div><div style="width:18em;display:inline-block"></div>break;
<a name="line1240"></a><div class="linenumber">1240</div><div style="width:16em;display:inline-block"></div>}
<a name="line1241"></a><div class="linenumber">1241</div><div style="width:14em;display:inline-block"></div>}
<a name="line1242"></a><div class="linenumber">1242</div><div style="width:14em;display:inline-block"></div>if&nbsp;(fullMatch&nbsp;&amp;&amp;&nbsp;parts[j])&nbsp;{
<a name="line1243"></a><div class="linenumber">1243</div><div style="width:16em;display:inline-block"></div>partList.push(parts[j]);
<a name="line1244"></a><div class="linenumber">1244</div><div style="width:14em;display:inline-block"></div>}
<a name="line1245"></a><div class="linenumber">1245</div><div style="width:12em;display:inline-block"></div>}
<a name="line1246"></a><div class="linenumber">1246</div><div style="width:12em;display:inline-block"></div>if&nbsp;(partList.length&nbsp;===&nbsp;1)&nbsp;{
<a name="line1247"></a><div class="linenumber">1247</div><div style="width:14em;display:inline-block"></div>for&nbsp;(j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;partList.length;&nbsp;j++)&nbsp;{
<a name="line1248"></a><div class="linenumber">1248</div><div style="width:16em;display:inline-block"></div>part&nbsp;=&nbsp;partList[j];
<a name="line1249"></a><div class="linenumber">1249</div><div style="width:16em;display:inline-block"></div>if&nbsp;(part)&nbsp;{
<a name="line1250"></a><div class="linenumber">1250</div><div style="width:18em;display:inline-block"></div>for&nbsp;(itemKey&nbsp;in&nbsp;itemKeys)&nbsp;{
<a name="line1251"></a><div class="linenumber">1251</div><div style="width:20em;display:inline-block"></div>if&nbsp;(itemKeys.hasOwnProperty(itemKey))&nbsp;{
<a name="line1252"></a><div class="linenumber">1252</div><div style="width:22em;display:inline-block"></div>userKey&nbsp;=&nbsp;itemKeys[itemKey];
<a name="line1253"></a><div class="linenumber">1253</div><div style="width:22em;display:inline-block"></div>localStats[userKey]&nbsp;=&nbsp;part.stat(itemKey);
<a name="line1254"></a><div class="linenumber">1254</div><div style="width:20em;display:inline-block"></div>}
<a name="line1255"></a><div class="linenumber">1255</div><div style="width:18em;display:inline-block"></div>}
<a name="line1256"></a><div class="linenumber">1256</div><div style="width:16em;display:inline-block"></div>}
<a name="line1257"></a><div class="linenumber">1257</div><div style="width:14em;display:inline-block"></div>}
<a name="line1258"></a><div class="linenumber">1258</div><div style="width:12em;display:inline-block"></div>}
<a name="line1259"></a><div class="linenumber">1259</div><div style="width:12em;display:inline-block"></div>else&nbsp;if&nbsp;(partList.length&nbsp;&gt;&nbsp;1)&nbsp;{
<a name="line1260"></a><div class="linenumber">1260</div><div style="width:14em;display:inline-block"></div>for&nbsp;(itemKey&nbsp;in&nbsp;itemKeys)&nbsp;{
<a name="line1261"></a><div class="linenumber">1261</div><div style="width:16em;display:inline-block"></div>if&nbsp;(itemKeys.hasOwnProperty(itemKey))&nbsp;{
<a name="line1262"></a><div class="linenumber">1262</div><div style="width:18em;display:inline-block"></div>localStats[itemKeys[itemKey]]&nbsp;=&nbsp;[];
<a name="line1263"></a><div class="linenumber">1263</div><div style="width:16em;display:inline-block"></div>}
<a name="line1264"></a><div class="linenumber">1264</div><div style="width:14em;display:inline-block"></div>}
<a name="line1265"></a><div class="linenumber">1265</div><div style="width:14em;display:inline-block"></div>for&nbsp;(j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;partList.length;&nbsp;j++)&nbsp;{
<a name="line1266"></a><div class="linenumber">1266</div><div style="width:16em;display:inline-block"></div>part&nbsp;=&nbsp;partList[j];
<a name="line1267"></a><div class="linenumber">1267</div><div style="width:18em;display:inline-block"></div>for&nbsp;(itemKey&nbsp;in&nbsp;itemKeys)&nbsp;{
<a name="line1268"></a><div class="linenumber">1268</div><div style="width:20em;display:inline-block"></div>if&nbsp;(itemKeys.hasOwnProperty(itemKey))&nbsp;{
<a name="line1269"></a><div class="linenumber">1269</div><div style="width:22em;display:inline-block"></div>userKey&nbsp;=&nbsp;itemKeys[itemKey];
<a name="line1270"></a><div class="linenumber">1270</div><div style="width:22em;display:inline-block"></div>localStats[userKey].push(part.stat(itemKey));
<a name="line1271"></a><div class="linenumber">1271</div><div style="width:20em;display:inline-block"></div>}
<a name="line1272"></a><div class="linenumber">1272</div><div style="width:18em;display:inline-block"></div>}
<a name="line1273"></a><div class="linenumber">1273</div><div style="width:14em;display:inline-block"></div>}
<a name="line1274"></a><div class="linenumber">1274</div><div style="width:12em;display:inline-block"></div>}
<a name="line1275"></a><div class="linenumber">1275</div><div style="width:10em;display:inline-block"></div>}
<a name="line1276"></a><div class="linenumber">1276</div><div style="width:8em;display:inline-block"></div>}
<a name="line1277"></a><div class="linenumber">1277</div>
<a name="line1278"></a><div class="linenumber">1278</div><div style="width:8em;display:inline-block"></div>if&nbsp;(localStats.remoteAddress&nbsp;&amp;&amp;&nbsp;turnAddress)&nbsp;{
<a name="line1279"></a><div class="linenumber">1279</div><div style="width:10em;display:inline-block"></div>localStats.remoteAddress&nbsp;=&nbsp;turnAddress;
<a name="line1280"></a><div class="linenumber">1280</div><div style="width:8em;display:inline-block"></div>}
<a name="line1281"></a><div class="linenumber">1281</div><div style="width:8em;display:inline-block"></div>callback(peerId,&nbsp;localStats);
<a name="line1282"></a><div class="linenumber">1282</div><div style="width:6em;display:inline-block"></div>});
<a name="line1283"></a><div class="linenumber">1283</div><div style="width:4em;display:inline-block"></div>}
<a name="line1284"></a><div class="linenumber">1284</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1285"></a><div class="linenumber">1285</div><div style="width:6em;display:inline-block"></div>callback(peerId,&nbsp;{"statistics":&nbsp;self.getConstantString("statsNotSupported")});
<a name="line1286"></a><div class="linenumber">1286</div><div style="width:4em;display:inline-block"></div>}
<a name="line1287"></a><div class="linenumber">1287</div><div style="width:2em;display:inline-block"></div>}
<a name="line1288"></a><div class="linenumber">1288</div>
<a name="line1289"></a><div class="linenumber">1289</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1290"></a><div class="linenumber">1290</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;gets&nbsp;the&nbsp;statistics&nbsp;for&nbsp;a&nbsp;particular&nbsp;peer&nbsp;connection.
<a name="line1291"></a><div class="linenumber">1291</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid
<a name="line1292"></a><div class="linenumber">1292</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callback&nbsp;gets&nbsp;the&nbsp;easyrtcid&nbsp;for&nbsp;the&nbsp;peer&nbsp;and&nbsp;a&nbsp;map&nbsp;of&nbsp;{userDefinedKey:&nbsp;value}.&nbsp;If&nbsp;there&nbsp;is&nbsp;no&nbsp;peer&nbsp;connection&nbsp;to&nbsp;easyrtcid,&nbsp;then&nbsp;the&nbsp;map&nbsp;will
<a name="line1293"></a><div class="linenumber">1293</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;have&nbsp;a&nbsp;value&nbsp;of&nbsp;{connected:false}.
<a name="line1294"></a><div class="linenumber">1294</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;filter&nbsp;depends&nbsp;on&nbsp;whether&nbsp;Chrome&nbsp;or&nbsp;Firefox&nbsp;is&nbsp;used.&nbsp;See&nbsp;the&nbsp;default&nbsp;filters&nbsp;for&nbsp;guidance.
<a name="line1295"></a><div class="linenumber">1295</div><div style="width:2em;display:inline-block"></div>*&nbsp;It&nbsp;is&nbsp;still&nbsp;experimental.
<a name="line1296"></a><div class="linenumber">1296</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1297"></a><div class="linenumber">1297</div><div style="width:2em;display:inline-block"></div>this.getPeerStatistics&nbsp;=&nbsp;function(easyrtcid,&nbsp;callback,&nbsp;filter)&nbsp;{
<a name="line1298"></a><div class="linenumber">1298</div><div style="width:4em;display:inline-block"></div>if&nbsp;(
<a name="line1299"></a><div class="linenumber">1299</div><div style="width:6em;display:inline-block"></div>adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line1300"></a><div class="linenumber">1300</div><div style="width:8em;display:inline-block"></div>adapter.browserDetails.browser&nbsp;===&nbsp;"firefox"
<a name="line1301"></a><div class="linenumber">1301</div><div style="width:4em;display:inline-block"></div>)&nbsp;{
<a name="line1302"></a><div class="linenumber">1302</div><div style="width:6em;display:inline-block"></div>getFirefoxPeerStatistics(easyrtcid,&nbsp;callback,&nbsp;filter);
<a name="line1303"></a><div class="linenumber">1303</div><div style="width:4em;display:inline-block"></div>}
<a name="line1304"></a><div class="linenumber">1304</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1305"></a><div class="linenumber">1305</div><div style="width:6em;display:inline-block"></div>getChromePeerStatistics(easyrtcid,&nbsp;callback,&nbsp;filter);
<a name="line1306"></a><div class="linenumber">1306</div><div style="width:4em;display:inline-block"></div>}
<a name="line1307"></a><div class="linenumber">1307</div><div style="width:2em;display:inline-block"></div>};
<a name="line1308"></a><div class="linenumber">1308</div>
<a name="line1309"></a><div class="linenumber">1309</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1310"></a><div class="linenumber">1310</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line1311"></a><div class="linenumber">1311</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;roomName
<a name="line1312"></a><div class="linenumber">1312</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;fields
<a name="line1313"></a><div class="linenumber">1313</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1314"></a><div class="linenumber">1314</div><div style="width:2em;display:inline-block"></div>function&nbsp;sendRoomApiFields(roomName,&nbsp;fields)&nbsp;{
<a name="line1315"></a><div class="linenumber">1315</div><div style="width:4em;display:inline-block"></div>var&nbsp;fieldAsString&nbsp;=&nbsp;JSON.stringify(fields);
<a name="line1316"></a><div class="linenumber">1316</div><div style="width:4em;display:inline-block"></div>JSON.parse(fieldAsString);
<a name="line1317"></a><div class="linenumber">1317</div><div style="width:4em;display:inline-block"></div>var&nbsp;dataToShip&nbsp;=&nbsp;{
<a name="line1318"></a><div class="linenumber">1318</div><div style="width:6em;display:inline-block"></div>msgType:&nbsp;"setRoomApiField",
<a name="line1319"></a><div class="linenumber">1319</div><div style="width:6em;display:inline-block"></div>msgData:&nbsp;{
<a name="line1320"></a><div class="linenumber">1320</div><div style="width:8em;display:inline-block"></div>setRoomApiField:&nbsp;{
<a name="line1321"></a><div class="linenumber">1321</div><div style="width:10em;display:inline-block"></div>roomName:&nbsp;roomName,
<a name="line1322"></a><div class="linenumber">1322</div><div style="width:10em;display:inline-block"></div>field:&nbsp;fields
<a name="line1323"></a><div class="linenumber">1323</div><div style="width:8em;display:inline-block"></div>}
<a name="line1324"></a><div class="linenumber">1324</div><div style="width:6em;display:inline-block"></div>}
<a name="line1325"></a><div class="linenumber">1325</div><div style="width:4em;display:inline-block"></div>};
<a name="line1326"></a><div class="linenumber">1326</div><div style="width:4em;display:inline-block"></div>self.webSocket.json.emit("easyrtcCmd",&nbsp;dataToShip,
<a name="line1327"></a><div class="linenumber">1327</div><div style="width:8em;display:inline-block"></div>function(ackMsg)&nbsp;{
<a name="line1328"></a><div class="linenumber">1328</div><div style="width:10em;display:inline-block"></div>if&nbsp;(ackMsg.msgType&nbsp;===&nbsp;"error")&nbsp;{
<a name="line1329"></a><div class="linenumber">1329</div><div style="width:12em;display:inline-block"></div>self.showError(ackMsg.msgData.errorCode,&nbsp;ackMsg.msgData.errorText);
<a name="line1330"></a><div class="linenumber">1330</div><div style="width:10em;display:inline-block"></div>}
<a name="line1331"></a><div class="linenumber">1331</div><div style="width:8em;display:inline-block"></div>}
<a name="line1332"></a><div class="linenumber">1332</div><div style="width:4em;display:inline-block"></div>);
<a name="line1333"></a><div class="linenumber">1333</div><div style="width:2em;display:inline-block"></div>}
<a name="line1334"></a><div class="linenumber">1334</div>
<a name="line1335"></a><div class="linenumber">1335</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line1336"></a><div class="linenumber">1336</div><div style="width:2em;display:inline-block"></div>var&nbsp;roomApiFieldTimer&nbsp;=&nbsp;null;
<a name="line1337"></a><div class="linenumber">1337</div>
<a name="line1338"></a><div class="linenumber">1338</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1339"></a><div class="linenumber">1339</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line1340"></a><div class="linenumber">1340</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;roomName
<a name="line1341"></a><div class="linenumber">1341</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1342"></a><div class="linenumber">1342</div><div style="width:2em;display:inline-block"></div>function&nbsp;enqueueSendRoomApi(roomName)&nbsp;{
<a name="line1343"></a><div class="linenumber">1343</div><div style="width:4em;display:inline-block"></div>//
<a name="line1344"></a><div class="linenumber">1344</div><div style="width:4em;display:inline-block"></div>//&nbsp;Rather&nbsp;than&nbsp;issue&nbsp;the&nbsp;send&nbsp;request&nbsp;immediately,&nbsp;we&nbsp;set&nbsp;a&nbsp;timer&nbsp;so&nbsp;we&nbsp;can&nbsp;accumulate&nbsp;other
<a name="line1345"></a><div class="linenumber">1345</div><div style="width:4em;display:inline-block"></div>//&nbsp;calls
<a name="line1346"></a><div class="linenumber">1346</div><div style="width:4em;display:inline-block"></div>//
<a name="line1347"></a><div class="linenumber">1347</div><div style="width:4em;display:inline-block"></div>if&nbsp;(roomApiFieldTimer)&nbsp;{
<a name="line1348"></a><div class="linenumber">1348</div><div style="width:6em;display:inline-block"></div>clearTimeout(roomApiFieldTimer);
<a name="line1349"></a><div class="linenumber">1349</div><div style="width:4em;display:inline-block"></div>}
<a name="line1350"></a><div class="linenumber">1350</div><div style="width:4em;display:inline-block"></div>roomApiFieldTimer&nbsp;=&nbsp;setTimeout(function()&nbsp;{
<a name="line1351"></a><div class="linenumber">1351</div><div style="width:6em;display:inline-block"></div>sendRoomApiFields(roomName,&nbsp;self._roomApiFields[roomName]);
<a name="line1352"></a><div class="linenumber">1352</div><div style="width:6em;display:inline-block"></div>roomApiFieldTimer&nbsp;=&nbsp;null;
<a name="line1353"></a><div class="linenumber">1353</div><div style="width:4em;display:inline-block"></div>},&nbsp;10);
<a name="line1354"></a><div class="linenumber">1354</div><div style="width:2em;display:inline-block"></div>}
<a name="line1355"></a><div class="linenumber">1355</div>
<a name="line1356"></a><div class="linenumber">1356</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Provide&nbsp;a&nbsp;set&nbsp;of&nbsp;application&nbsp;defined&nbsp;fields&nbsp;that&nbsp;will&nbsp;be&nbsp;part&nbsp;of&nbsp;this&nbsp;instances
<a name="line1357"></a><div class="linenumber">1357</div><div style="width:2em;display:inline-block"></div>*&nbsp;configuration&nbsp;information.&nbsp;This&nbsp;data&nbsp;will&nbsp;get&nbsp;sent&nbsp;to&nbsp;other&nbsp;peers&nbsp;via&nbsp;the&nbsp;websocket
<a name="line1358"></a><div class="linenumber">1358</div><div style="width:2em;display:inline-block"></div>*&nbsp;path.
<a name="line1359"></a><div class="linenumber">1359</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;roomName&nbsp;-&nbsp;the&nbsp;room&nbsp;the&nbsp;field&nbsp;is&nbsp;attached&nbsp;to.
<a name="line1360"></a><div class="linenumber">1360</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;fieldName&nbsp;-&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;field.
<a name="line1361"></a><div class="linenumber">1361</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;fieldValue&nbsp;-&nbsp;the&nbsp;value&nbsp;of&nbsp;the&nbsp;field.
<a name="line1362"></a><div class="linenumber">1362</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1363"></a><div class="linenumber">1363</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;easyrtc.setRoomApiField("trekkieRoom",&nbsp;&nbsp;"favorite_alien",&nbsp;"Mr&nbsp;Spock");
<a name="line1364"></a><div class="linenumber">1364</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;easyrtc.setRoomOccupantListener(&nbsp;function(roomName,&nbsp;list){
<a name="line1365"></a><div class="linenumber">1365</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(&nbsp;var&nbsp;i&nbsp;in&nbsp;list&nbsp;){
<a name="line1366"></a><div class="linenumber">1366</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("easyrtcid="&nbsp;+&nbsp;i&nbsp;+&nbsp;"&nbsp;favorite&nbsp;alien&nbsp;is&nbsp;"&nbsp;+&nbsp;list[i].apiFields.favorite_alien);
<a name="line1367"></a><div class="linenumber">1367</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line1368"></a><div class="linenumber">1368</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;});
<a name="line1369"></a><div class="linenumber">1369</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1370"></a><div class="linenumber">1370</div><div style="width:2em;display:inline-block"></div>this.setRoomApiField&nbsp;=&nbsp;function(roomName,&nbsp;fieldName,&nbsp;fieldValue)&nbsp;{
<a name="line1371"></a><div class="linenumber">1371</div><div style="width:4em;display:inline-block"></div>//
<a name="line1372"></a><div class="linenumber">1372</div><div style="width:4em;display:inline-block"></div>//&nbsp;if&nbsp;we're&nbsp;not&nbsp;connected&nbsp;yet,&nbsp;we'll&nbsp;just&nbsp;cache&nbsp;the&nbsp;fields&nbsp;until&nbsp;we&nbsp;are.
<a name="line1373"></a><div class="linenumber">1373</div><div style="width:4em;display:inline-block"></div>//
<a name="line1374"></a><div class="linenumber">1374</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self._roomApiFields)&nbsp;{
<a name="line1375"></a><div class="linenumber">1375</div><div style="width:6em;display:inline-block"></div>self._roomApiFields&nbsp;=&nbsp;{};
<a name="line1376"></a><div class="linenumber">1376</div><div style="width:4em;display:inline-block"></div>}
<a name="line1377"></a><div class="linenumber">1377</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!fieldName&nbsp;&amp;&amp;&nbsp;!fieldValue)&nbsp;{
<a name="line1378"></a><div class="linenumber">1378</div><div style="width:6em;display:inline-block"></div>delete&nbsp;self._roomApiFields[roomName];
<a name="line1379"></a><div class="linenumber">1379</div><div style="width:6em;display:inline-block"></div>return;
<a name="line1380"></a><div class="linenumber">1380</div><div style="width:4em;display:inline-block"></div>}
<a name="line1381"></a><div class="linenumber">1381</div>
<a name="line1382"></a><div class="linenumber">1382</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self._roomApiFields[roomName])&nbsp;{
<a name="line1383"></a><div class="linenumber">1383</div><div style="width:6em;display:inline-block"></div>self._roomApiFields[roomName]&nbsp;=&nbsp;{};
<a name="line1384"></a><div class="linenumber">1384</div><div style="width:4em;display:inline-block"></div>}
<a name="line1385"></a><div class="linenumber">1385</div><div style="width:4em;display:inline-block"></div>if&nbsp;(fieldValue&nbsp;!==&nbsp;undefined&nbsp;&amp;&amp;&nbsp;fieldValue&nbsp;!==&nbsp;null)&nbsp;{
<a name="line1386"></a><div class="linenumber">1386</div><div style="width:6em;display:inline-block"></div>if&nbsp;(typeof&nbsp;fieldValue&nbsp;===&nbsp;"object")&nbsp;{
<a name="line1387"></a><div class="linenumber">1387</div><div style="width:8em;display:inline-block"></div>try&nbsp;{
<a name="line1388"></a><div class="linenumber">1388</div><div style="width:10em;display:inline-block"></div>JSON.stringify(fieldValue);
<a name="line1389"></a><div class="linenumber">1389</div><div style="width:8em;display:inline-block"></div>}
<a name="line1390"></a><div class="linenumber">1390</div><div style="width:8em;display:inline-block"></div>catch&nbsp;(jsonError)&nbsp;{
<a name="line1391"></a><div class="linenumber">1391</div><div style="width:10em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"easyrtc.setRoomApiField&nbsp;passed&nbsp;bad&nbsp;object&nbsp;");
<a name="line1392"></a><div class="linenumber">1392</div><div style="width:10em;display:inline-block"></div>return;
<a name="line1393"></a><div class="linenumber">1393</div><div style="width:8em;display:inline-block"></div>}
<a name="line1394"></a><div class="linenumber">1394</div><div style="width:6em;display:inline-block"></div>}
<a name="line1395"></a><div class="linenumber">1395</div><div style="width:6em;display:inline-block"></div>self._roomApiFields[roomName][fieldName]&nbsp;=&nbsp;{fieldName:&nbsp;fieldName,&nbsp;fieldValue:&nbsp;fieldValue};
<a name="line1396"></a><div class="linenumber">1396</div><div style="width:4em;display:inline-block"></div>}
<a name="line1397"></a><div class="linenumber">1397</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1398"></a><div class="linenumber">1398</div><div style="width:6em;display:inline-block"></div>delete&nbsp;self._roomApiFields[roomName][fieldName];
<a name="line1399"></a><div class="linenumber">1399</div><div style="width:4em;display:inline-block"></div>}
<a name="line1400"></a><div class="linenumber">1400</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.webSocketConnected)&nbsp;{
<a name="line1401"></a><div class="linenumber">1401</div><div style="width:6em;display:inline-block"></div>enqueueSendRoomApi(roomName);
<a name="line1402"></a><div class="linenumber">1402</div><div style="width:4em;display:inline-block"></div>}
<a name="line1403"></a><div class="linenumber">1403</div><div style="width:2em;display:inline-block"></div>};
<a name="line1404"></a><div class="linenumber">1404</div>
<a name="line1405"></a><div class="linenumber">1405</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1406"></a><div class="linenumber">1406</div><div style="width:2em;display:inline-block"></div>*&nbsp;Default&nbsp;error&nbsp;reporting&nbsp;function.&nbsp;The&nbsp;default&nbsp;implementation&nbsp;displays&nbsp;error&nbsp;messages
<a name="line1407"></a><div class="linenumber">1407</div><div style="width:2em;display:inline-block"></div>*&nbsp;in&nbsp;a&nbsp;programmatically&nbsp;created&nbsp;div&nbsp;with&nbsp;the&nbsp;id&nbsp;easyrtcErrorDialog.&nbsp;The&nbsp;div&nbsp;has&nbsp;title
<a name="line1408"></a><div class="linenumber">1408</div><div style="width:2em;display:inline-block"></div>*&nbsp;component&nbsp;with&nbsp;a&nbsp;class&nbsp;name&nbsp;of&nbsp;easyrtcErrorDialog_title.&nbsp;The&nbsp;error&nbsp;messages&nbsp;get&nbsp;added&nbsp;to&nbsp;a
<a name="line1409"></a><div class="linenumber">1409</div><div style="width:2em;display:inline-block"></div>*&nbsp;container&nbsp;with&nbsp;the&nbsp;id&nbsp;easyrtcErrorDialog_body.&nbsp;Each&nbsp;error&nbsp;message&nbsp;is&nbsp;a&nbsp;text&nbsp;node&nbsp;inside&nbsp;a&nbsp;div
<a name="line1410"></a><div class="linenumber">1410</div><div style="width:2em;display:inline-block"></div>*&nbsp;with&nbsp;a&nbsp;class&nbsp;of&nbsp;easyrtcErrorDialog_element.&nbsp;There&nbsp;is&nbsp;an&nbsp;"okay"&nbsp;button&nbsp;with&nbsp;the&nbsp;className&nbsp;of&nbsp;easyrtcErrorDialog_okayButton.
<a name="line1411"></a><div class="linenumber">1411</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;messageCode&nbsp;An&nbsp;error&nbsp;message&nbsp;code
<a name="line1412"></a><div class="linenumber">1412</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;message&nbsp;the&nbsp;error&nbsp;message&nbsp;text&nbsp;without&nbsp;any&nbsp;markup.
<a name="line1413"></a><div class="linenumber">1413</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1414"></a><div class="linenumber">1414</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.showError("BAD_NAME",&nbsp;"Invalid&nbsp;username");
<a name="line1415"></a><div class="linenumber">1415</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1416"></a><div class="linenumber">1416</div><div style="width:2em;display:inline-block"></div>this.showError&nbsp;=&nbsp;function(messageCode,&nbsp;message)&nbsp;{
<a name="line1417"></a><div class="linenumber">1417</div><div style="width:4em;display:inline-block"></div>self.onError({errorCode:&nbsp;messageCode,&nbsp;errorText:&nbsp;message});
<a name="line1418"></a><div class="linenumber">1418</div><div style="width:2em;display:inline-block"></div>};
<a name="line1419"></a><div class="linenumber">1419</div>
<a name="line1420"></a><div class="linenumber">1420</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1421"></a><div class="linenumber">1421</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line1422"></a><div class="linenumber">1422</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;errorObject
<a name="line1423"></a><div class="linenumber">1423</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1424"></a><div class="linenumber">1424</div><div style="width:2em;display:inline-block"></div>this.onError&nbsp;=&nbsp;function(errorObject)&nbsp;{
<a name="line1425"></a><div class="linenumber">1425</div><div style="width:4em;display:inline-block"></div>logDebug("saw&nbsp;error&nbsp;"&nbsp;+&nbsp;errorObject.errorText);
<a name="line1426"></a><div class="linenumber">1426</div>
<a name="line1427"></a><div class="linenumber">1427</div><div style="width:4em;display:inline-block"></div>var&nbsp;errorDiv&nbsp;=&nbsp;document.getElementById('easyrtcErrorDialog');
<a name="line1428"></a><div class="linenumber">1428</div><div style="width:4em;display:inline-block"></div>var&nbsp;errorBody;
<a name="line1429"></a><div class="linenumber">1429</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!errorDiv)&nbsp;{
<a name="line1430"></a><div class="linenumber">1430</div><div style="width:6em;display:inline-block"></div>errorDiv&nbsp;=&nbsp;document.createElement("div");
<a name="line1431"></a><div class="linenumber">1431</div><div style="width:6em;display:inline-block"></div>errorDiv.id&nbsp;=&nbsp;'easyrtcErrorDialog';
<a name="line1432"></a><div class="linenumber">1432</div><div style="width:6em;display:inline-block"></div>var&nbsp;title&nbsp;=&nbsp;document.createElement("div");
<a name="line1433"></a><div class="linenumber">1433</div><div style="width:6em;display:inline-block"></div>title.innerHTML&nbsp;=&nbsp;"Error&nbsp;messages";
<a name="line1434"></a><div class="linenumber">1434</div><div style="width:6em;display:inline-block"></div>title.className&nbsp;=&nbsp;"easyrtcErrorDialog_title";
<a name="line1435"></a><div class="linenumber">1435</div><div style="width:6em;display:inline-block"></div>errorDiv.appendChild(title);
<a name="line1436"></a><div class="linenumber">1436</div><div style="width:6em;display:inline-block"></div>errorBody&nbsp;=&nbsp;document.createElement("div");
<a name="line1437"></a><div class="linenumber">1437</div><div style="width:6em;display:inline-block"></div>errorBody.id&nbsp;=&nbsp;"easyrtcErrorDialog_body";
<a name="line1438"></a><div class="linenumber">1438</div><div style="width:6em;display:inline-block"></div>errorDiv.appendChild(errorBody);
<a name="line1439"></a><div class="linenumber">1439</div><div style="width:6em;display:inline-block"></div>var&nbsp;clearButton&nbsp;=&nbsp;document.createElement("button");
<a name="line1440"></a><div class="linenumber">1440</div><div style="width:6em;display:inline-block"></div>clearButton.appendChild(document.createTextNode("Okay"));
<a name="line1441"></a><div class="linenumber">1441</div><div style="width:6em;display:inline-block"></div>clearButton.className&nbsp;=&nbsp;"easyrtcErrorDialog_okayButton";
<a name="line1442"></a><div class="linenumber">1442</div><div style="width:6em;display:inline-block"></div>clearButton.onclick&nbsp;=&nbsp;function()&nbsp;{
<a name="line1443"></a><div class="linenumber">1443</div><div style="width:8em;display:inline-block"></div>errorBody.innerHTML&nbsp;=&nbsp;"";&nbsp;//&nbsp;remove&nbsp;all&nbsp;inner&nbsp;nodes
<a name="line1444"></a><div class="linenumber">1444</div><div style="width:8em;display:inline-block"></div>errorDiv.style.display&nbsp;=&nbsp;"none";
<a name="line1445"></a><div class="linenumber">1445</div><div style="width:6em;display:inline-block"></div>};
<a name="line1446"></a><div class="linenumber">1446</div><div style="width:6em;display:inline-block"></div>errorDiv.appendChild(clearButton);
<a name="line1447"></a><div class="linenumber">1447</div><div style="width:6em;display:inline-block"></div>document.body.appendChild(errorDiv);
<a name="line1448"></a><div class="linenumber">1448</div><div style="width:4em;display:inline-block"></div>}
<a name="line1449"></a><div class="linenumber">1449</div>
<a name="line1450"></a><div class="linenumber">1450</div><div style="width:4em;display:inline-block"></div>errorBody&nbsp;=&nbsp;document.getElementById("easyrtcErrorDialog_body");
<a name="line1451"></a><div class="linenumber">1451</div><div style="width:4em;display:inline-block"></div>var&nbsp;messageNode&nbsp;=&nbsp;document.createElement("div");
<a name="line1452"></a><div class="linenumber">1452</div><div style="width:4em;display:inline-block"></div>messageNode.className&nbsp;=&nbsp;'easyrtcErrorDialog_element';
<a name="line1453"></a><div class="linenumber">1453</div><div style="width:4em;display:inline-block"></div>messageNode.appendChild(document.createTextNode(errorObject.errorText));
<a name="line1454"></a><div class="linenumber">1454</div><div style="width:4em;display:inline-block"></div>errorBody.appendChild(messageNode);
<a name="line1455"></a><div class="linenumber">1455</div><div style="width:4em;display:inline-block"></div>errorDiv.style.display&nbsp;=&nbsp;"block";
<a name="line1456"></a><div class="linenumber">1456</div><div style="width:2em;display:inline-block"></div>};
<a name="line1457"></a><div class="linenumber">1457</div>
<a name="line1458"></a><div class="linenumber">1458</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line1459"></a><div class="linenumber">1459</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;mediaStream&nbsp;*/
<a name="line1460"></a><div class="linenumber">1460</div><div style="width:2em;display:inline-block"></div>//
<a name="line1461"></a><div class="linenumber">1461</div><div style="width:2em;display:inline-block"></div>//&nbsp;easyrtc.createObjectURL&nbsp;builds&nbsp;a&nbsp;URL&nbsp;from&nbsp;a&nbsp;media&nbsp;stream.
<a name="line1462"></a><div class="linenumber">1462</div><div style="width:2em;display:inline-block"></div>//&nbsp;Arguments:
<a name="line1463"></a><div class="linenumber">1463</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mediaStream&nbsp;-&nbsp;a&nbsp;media&nbsp;stream&nbsp;object.
<a name="line1464"></a><div class="linenumber">1464</div><div style="width:2em;display:inline-block"></div>//&nbsp;The&nbsp;video&nbsp;object&nbsp;in&nbsp;Chrome&nbsp;expects&nbsp;a&nbsp;URL.
<a name="line1465"></a><div class="linenumber">1465</div><div style="width:2em;display:inline-block"></div>//
<a name="line1466"></a><div class="linenumber">1466</div><div style="width:2em;display:inline-block"></div>this.createObjectURL&nbsp;=&nbsp;function(mediaStream)&nbsp;{
<a name="line1467"></a><div class="linenumber">1467</div><div style="width:4em;display:inline-block"></div>var&nbsp;errMessage;
<a name="line1468"></a><div class="linenumber">1468</div><div style="width:4em;display:inline-block"></div>if&nbsp;(window.URL&nbsp;&amp;&amp;&nbsp;window.URL.createObjectURL)&nbsp;{
<a name="line1469"></a><div class="linenumber">1469</div><div style="width:6em;display:inline-block"></div>return&nbsp;window.URL.createObjectURL(mediaStream);
<a name="line1470"></a><div class="linenumber">1470</div><div style="width:4em;display:inline-block"></div>}
<a name="line1471"></a><div class="linenumber">1471</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(window.webkitURL&nbsp;&amp;&amp;&nbsp;window.webkitURL.createObjectURL)&nbsp;{
<a name="line1472"></a><div class="linenumber">1472</div><div style="width:6em;display:inline-block"></div>return&nbsp;window.webkit.createObjectURL(mediaStream);
<a name="line1473"></a><div class="linenumber">1473</div><div style="width:4em;display:inline-block"></div>}
<a name="line1474"></a><div class="linenumber">1474</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1475"></a><div class="linenumber">1475</div><div style="width:6em;display:inline-block"></div>errMessage&nbsp;=&nbsp;"Your&nbsp;browsers&nbsp;does&nbsp;not&nbsp;support&nbsp;URL.createObjectURL.";
<a name="line1476"></a><div class="linenumber">1476</div><div style="width:6em;display:inline-block"></div>logDebug("saw&nbsp;exception&nbsp;"&nbsp;+&nbsp;errMessage);
<a name="line1477"></a><div class="linenumber">1477</div><div style="width:6em;display:inline-block"></div>throw&nbsp;errMessage;
<a name="line1478"></a><div class="linenumber">1478</div><div style="width:4em;display:inline-block"></div>}
<a name="line1479"></a><div class="linenumber">1479</div><div style="width:2em;display:inline-block"></div>};
<a name="line1480"></a><div class="linenumber">1480</div>
<a name="line1481"></a><div class="linenumber">1481</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1482"></a><div class="linenumber">1482</div><div style="width:2em;display:inline-block"></div>*&nbsp;A&nbsp;convenience&nbsp;function&nbsp;to&nbsp;ensure&nbsp;that&nbsp;a&nbsp;string&nbsp;doesn't&nbsp;have&nbsp;symbols&nbsp;that&nbsp;will&nbsp;be&nbsp;interpreted&nbsp;by&nbsp;HTML.
<a name="line1483"></a><div class="linenumber">1483</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;idString
<a name="line1484"></a><div class="linenumber">1484</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{String}&nbsp;The&nbsp;cleaned&nbsp;string.
<a name="line1485"></a><div class="linenumber">1485</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1486"></a><div class="linenumber">1486</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;console.log(&nbsp;easyrtc.cleanId('&amp;hello'));
<a name="line1487"></a><div class="linenumber">1487</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1488"></a><div class="linenumber">1488</div><div style="width:2em;display:inline-block"></div>this.cleanId&nbsp;=&nbsp;function(idString)&nbsp;{
<a name="line1489"></a><div class="linenumber">1489</div><div style="width:4em;display:inline-block"></div>var&nbsp;MAP&nbsp;=&nbsp;{
<a name="line1490"></a><div class="linenumber">1490</div><div style="width:6em;display:inline-block"></div>'&amp;':&nbsp;'&amp;amp;',
<a name="line1491"></a><div class="linenumber">1491</div><div style="width:6em;display:inline-block"></div>'&lt;':&nbsp;'&amp;lt;',
<a name="line1492"></a><div class="linenumber">1492</div><div style="width:6em;display:inline-block"></div>'&gt;':&nbsp;'&amp;gt;'
<a name="line1493"></a><div class="linenumber">1493</div><div style="width:4em;display:inline-block"></div>};
<a name="line1494"></a><div class="linenumber">1494</div><div style="width:4em;display:inline-block"></div>return&nbsp;idString.replace(/[&amp;&lt;&gt;]/g,&nbsp;function(c)&nbsp;{
<a name="line1495"></a><div class="linenumber">1495</div><div style="width:6em;display:inline-block"></div>return&nbsp;MAP[c];
<a name="line1496"></a><div class="linenumber">1496</div><div style="width:4em;display:inline-block"></div>});
<a name="line1497"></a><div class="linenumber">1497</div><div style="width:2em;display:inline-block"></div>};
<a name="line1498"></a><div class="linenumber">1498</div>
<a name="line1499"></a><div class="linenumber">1499</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1500"></a><div class="linenumber">1500</div><div style="width:2em;display:inline-block"></div>*&nbsp;Set&nbsp;a&nbsp;callback&nbsp;that&nbsp;will&nbsp;be&nbsp;invoked&nbsp;when&nbsp;the&nbsp;application&nbsp;enters&nbsp;or&nbsp;leaves&nbsp;a&nbsp;room.
<a name="line1501"></a><div class="linenumber">1501</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;handler&nbsp;-&nbsp;the&nbsp;first&nbsp;parameter&nbsp;is&nbsp;true&nbsp;for&nbsp;entering&nbsp;a&nbsp;room,&nbsp;false&nbsp;for&nbsp;leaving&nbsp;a&nbsp;room.&nbsp;The&nbsp;second&nbsp;parameter&nbsp;is&nbsp;the&nbsp;room&nbsp;name.
<a name="line1502"></a><div class="linenumber">1502</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1503"></a><div class="linenumber">1503</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;easyrtc.setRoomEntryListener(function(entry,&nbsp;roomName){
<a name="line1504"></a><div class="linenumber">1504</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;entry&nbsp;){
<a name="line1505"></a><div class="linenumber">1505</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("entering&nbsp;room&nbsp;"&nbsp;+&nbsp;roomName);
<a name="line1506"></a><div class="linenumber">1506</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line1507"></a><div class="linenumber">1507</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else{
<a name="line1508"></a><div class="linenumber">1508</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("leaving&nbsp;room&nbsp;"&nbsp;+&nbsp;roomName);
<a name="line1509"></a><div class="linenumber">1509</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line1510"></a><div class="linenumber">1510</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;});
<a name="line1511"></a><div class="linenumber">1511</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1512"></a><div class="linenumber">1512</div><div style="width:2em;display:inline-block"></div>self.setRoomEntryListener&nbsp;=&nbsp;function(handler)&nbsp;{
<a name="line1513"></a><div class="linenumber">1513</div><div style="width:4em;display:inline-block"></div>self.roomEntryListener&nbsp;=&nbsp;handler;
<a name="line1514"></a><div class="linenumber">1514</div><div style="width:2em;display:inline-block"></div>};
<a name="line1515"></a><div class="linenumber">1515</div>
<a name="line1516"></a><div class="linenumber">1516</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1517"></a><div class="linenumber">1517</div><div style="width:2em;display:inline-block"></div>*&nbsp;Set&nbsp;the&nbsp;callback&nbsp;that&nbsp;will&nbsp;be&nbsp;invoked&nbsp;when&nbsp;the&nbsp;list&nbsp;of&nbsp;people&nbsp;logged&nbsp;in&nbsp;changes.
<a name="line1518"></a><div class="linenumber">1518</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;callback&nbsp;expects&nbsp;to&nbsp;receive&nbsp;a&nbsp;room&nbsp;name&nbsp;argument,&nbsp;and
<a name="line1519"></a><div class="linenumber">1519</div><div style="width:2em;display:inline-block"></div>*&nbsp;a&nbsp;map&nbsp;whose&nbsp;ideas&nbsp;are&nbsp;easyrtcids&nbsp;and&nbsp;whose&nbsp;values&nbsp;are&nbsp;in&nbsp;turn&nbsp;maps
<a name="line1520"></a><div class="linenumber">1520</div><div style="width:2em;display:inline-block"></div>*&nbsp;supplying&nbsp;user&nbsp;specific&nbsp;information.&nbsp;The&nbsp;inner&nbsp;maps&nbsp;have&nbsp;the&nbsp;following&nbsp;keys:
<a name="line1521"></a><div class="linenumber">1521</div><div style="width:2em;display:inline-block"></div>*&nbsp;username,&nbsp;applicationName,&nbsp;browserFamily,&nbsp;browserMajor,&nbsp;osFamily,&nbsp;osMajor,&nbsp;deviceFamily.
<a name="line1522"></a><div class="linenumber">1522</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;third&nbsp;argument&nbsp;is&nbsp;the&nbsp;listener&nbsp;is&nbsp;the&nbsp;innerMap&nbsp;for&nbsp;the&nbsp;connections&nbsp;own&nbsp;data&nbsp;(not&nbsp;needed&nbsp;by&nbsp;most&nbsp;applications).
<a name="line1523"></a><div class="linenumber">1523</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener
<a name="line1524"></a><div class="linenumber">1524</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1525"></a><div class="linenumber">1525</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;easyrtc.setRoomOccupantListener(&nbsp;function(roomName,&nbsp;list,&nbsp;selfInfo){
<a name="line1526"></a><div class="linenumber">1526</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(&nbsp;var&nbsp;i&nbsp;in&nbsp;list&nbsp;){
<a name="line1527"></a><div class="linenumber">1527</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;("easyrtcid="&nbsp;+&nbsp;i&nbsp;+&nbsp;"&nbsp;belongs&nbsp;to&nbsp;user&nbsp;"&nbsp;+&nbsp;list[i].username);
<a name="line1528"></a><div class="linenumber">1528</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line1529"></a><div class="linenumber">1529</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;});
<a name="line1530"></a><div class="linenumber">1530</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1531"></a><div class="linenumber">1531</div><div style="width:2em;display:inline-block"></div>self.setRoomOccupantListener&nbsp;=&nbsp;function(listener)&nbsp;{
<a name="line1532"></a><div class="linenumber">1532</div><div style="width:4em;display:inline-block"></div>roomOccupantListener&nbsp;=&nbsp;listener;
<a name="line1533"></a><div class="linenumber">1533</div><div style="width:2em;display:inline-block"></div>};
<a name="line1534"></a><div class="linenumber">1534</div>
<a name="line1535"></a><div class="linenumber">1535</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1536"></a><div class="linenumber">1536</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;callback&nbsp;that&nbsp;is&nbsp;called&nbsp;when&nbsp;a&nbsp;data&nbsp;channel&nbsp;is&nbsp;open&nbsp;and&nbsp;ready&nbsp;to&nbsp;send&nbsp;data.
<a name="line1537"></a><div class="linenumber">1537</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;callback&nbsp;will&nbsp;be&nbsp;called&nbsp;with&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;it's&nbsp;sole&nbsp;argument.
<a name="line1538"></a><div class="linenumber">1538</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener
<a name="line1539"></a><div class="linenumber">1539</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1540"></a><div class="linenumber">1540</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setDataChannelOpenListener(&nbsp;function(easyrtcid){
<a name="line1541"></a><div class="linenumber">1541</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.sendDataP2P(easyrtcid,&nbsp;"greeting",&nbsp;"hello");
<a name="line1542"></a><div class="linenumber">1542</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line1543"></a><div class="linenumber">1543</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1544"></a><div class="linenumber">1544</div><div style="width:2em;display:inline-block"></div>this.setDataChannelOpenListener&nbsp;=&nbsp;function(listener)&nbsp;{
<a name="line1545"></a><div class="linenumber">1545</div><div style="width:4em;display:inline-block"></div>onDataChannelOpen&nbsp;=&nbsp;listener;
<a name="line1546"></a><div class="linenumber">1546</div><div style="width:2em;display:inline-block"></div>};
<a name="line1547"></a><div class="linenumber">1547</div>
<a name="line1548"></a><div class="linenumber">1548</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sets&nbsp;a&nbsp;callback&nbsp;that&nbsp;is&nbsp;called&nbsp;when&nbsp;a&nbsp;previously&nbsp;open&nbsp;data&nbsp;channel&nbsp;closes.
<a name="line1549"></a><div class="linenumber">1549</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;callback&nbsp;will&nbsp;be&nbsp;called&nbsp;with&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;it's&nbsp;sole&nbsp;argument.
<a name="line1550"></a><div class="linenumber">1550</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener
<a name="line1551"></a><div class="linenumber">1551</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1552"></a><div class="linenumber">1552</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setDataChannelCloseListener(&nbsp;function(easyrtcid){
<a name="line1553"></a><div class="linenumber">1553</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;("No&nbsp;longer&nbsp;connected&nbsp;to&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid));
<a name="line1554"></a><div class="linenumber">1554</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line1555"></a><div class="linenumber">1555</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1556"></a><div class="linenumber">1556</div><div style="width:2em;display:inline-block"></div>this.setDataChannelCloseListener&nbsp;=&nbsp;function(listener)&nbsp;{
<a name="line1557"></a><div class="linenumber">1557</div><div style="width:4em;display:inline-block"></div>onDataChannelClose&nbsp;=&nbsp;listener;
<a name="line1558"></a><div class="linenumber">1558</div><div style="width:2em;display:inline-block"></div>};
<a name="line1559"></a><div class="linenumber">1559</div>
<a name="line1560"></a><div class="linenumber">1560</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Returns&nbsp;the&nbsp;number&nbsp;of&nbsp;live&nbsp;peer&nbsp;connections&nbsp;the&nbsp;client&nbsp;has.
<a name="line1561"></a><div class="linenumber">1561</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Number}
<a name="line1562"></a><div class="linenumber">1562</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1563"></a><div class="linenumber">1563</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;("You&nbsp;have&nbsp;"&nbsp;+&nbsp;easyrtc.getConnectionCount()&nbsp;+&nbsp;"&nbsp;peer&nbsp;connections");
<a name="line1564"></a><div class="linenumber">1564</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1565"></a><div class="linenumber">1565</div><div style="width:2em;display:inline-block"></div>this.getConnectionCount&nbsp;=&nbsp;function()&nbsp;{
<a name="line1566"></a><div class="linenumber">1566</div><div style="width:4em;display:inline-block"></div>var&nbsp;count&nbsp;=&nbsp;0;
<a name="line1567"></a><div class="linenumber">1567</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line1568"></a><div class="linenumber">1568</div><div style="width:4em;display:inline-block"></div>for&nbsp;(i&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line1569"></a><div class="linenumber">1569</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns.hasOwnProperty(i))&nbsp;{
<a name="line1570"></a><div class="linenumber">1570</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.getConnectStatus(i)&nbsp;===&nbsp;self.IS_CONNECTED)&nbsp;{
<a name="line1571"></a><div class="linenumber">1571</div><div style="width:10em;display:inline-block"></div>count++;
<a name="line1572"></a><div class="linenumber">1572</div><div style="width:8em;display:inline-block"></div>}
<a name="line1573"></a><div class="linenumber">1573</div><div style="width:6em;display:inline-block"></div>}
<a name="line1574"></a><div class="linenumber">1574</div><div style="width:4em;display:inline-block"></div>}
<a name="line1575"></a><div class="linenumber">1575</div><div style="width:4em;display:inline-block"></div>return&nbsp;count;
<a name="line1576"></a><div class="linenumber">1576</div><div style="width:2em;display:inline-block"></div>};
<a name="line1577"></a><div class="linenumber">1577</div>
<a name="line1578"></a><div class="linenumber">1578</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sets&nbsp;the&nbsp;maximum&nbsp;length&nbsp;in&nbsp;bytes&nbsp;of&nbsp;P2P&nbsp;messages&nbsp;that&nbsp;can&nbsp;be&nbsp;sent.
<a name="line1579"></a><div class="linenumber">1579</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Number}&nbsp;maxLength&nbsp;maximum&nbsp;length&nbsp;to&nbsp;set
<a name="line1580"></a><div class="linenumber">1580</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1581"></a><div class="linenumber">1581</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setMaxP2PMessageLength(10000);
<a name="line1582"></a><div class="linenumber">1582</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1583"></a><div class="linenumber">1583</div><div style="width:2em;display:inline-block"></div>this.setMaxP2PMessageLength&nbsp;=&nbsp;function(maxLength)&nbsp;{
<a name="line1584"></a><div class="linenumber">1584</div><div style="width:4em;display:inline-block"></div>this.maxP2PMessageLength&nbsp;=&nbsp;maxLength;
<a name="line1585"></a><div class="linenumber">1585</div><div style="width:2em;display:inline-block"></div>};
<a name="line1586"></a><div class="linenumber">1586</div>
<a name="line1587"></a><div class="linenumber">1587</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sets&nbsp;whether&nbsp;audio&nbsp;is&nbsp;transmitted&nbsp;by&nbsp;the&nbsp;local&nbsp;user&nbsp;in&nbsp;any&nbsp;subsequent&nbsp;calls.
<a name="line1588"></a><div class="linenumber">1588</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enabled&nbsp;true&nbsp;to&nbsp;include&nbsp;audio,&nbsp;false&nbsp;to&nbsp;exclude&nbsp;audio.&nbsp;The&nbsp;default&nbsp;is&nbsp;true.
<a name="line1589"></a><div class="linenumber">1589</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1590"></a><div class="linenumber">1590</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.enableAudio(false);
<a name="line1591"></a><div class="linenumber">1591</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1592"></a><div class="linenumber">1592</div><div style="width:2em;display:inline-block"></div>this.enableAudio&nbsp;=&nbsp;function(enabled)&nbsp;{
<a name="line1593"></a><div class="linenumber">1593</div><div style="width:4em;display:inline-block"></div>self.audioEnabled&nbsp;=&nbsp;enabled;
<a name="line1594"></a><div class="linenumber">1594</div><div style="width:2em;display:inline-block"></div>};
<a name="line1595"></a><div class="linenumber">1595</div>
<a name="line1596"></a><div class="linenumber">1596</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1597"></a><div class="linenumber">1597</div><div style="width:2em;display:inline-block"></div>*Sets&nbsp;whether&nbsp;video&nbsp;is&nbsp;transmitted&nbsp;by&nbsp;the&nbsp;local&nbsp;user&nbsp;in&nbsp;any&nbsp;subsequent&nbsp;calls.
<a name="line1598"></a><div class="linenumber">1598</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enabled&nbsp;-&nbsp;true&nbsp;to&nbsp;include&nbsp;video,&nbsp;false&nbsp;to&nbsp;exclude&nbsp;video.&nbsp;The&nbsp;default&nbsp;is&nbsp;true.
<a name="line1599"></a><div class="linenumber">1599</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1600"></a><div class="linenumber">1600</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.enableVideo(false);
<a name="line1601"></a><div class="linenumber">1601</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1602"></a><div class="linenumber">1602</div><div style="width:2em;display:inline-block"></div>this.enableVideo&nbsp;=&nbsp;function(enabled)&nbsp;{
<a name="line1603"></a><div class="linenumber">1603</div><div style="width:4em;display:inline-block"></div>self.videoEnabled&nbsp;=&nbsp;enabled;
<a name="line1604"></a><div class="linenumber">1604</div><div style="width:2em;display:inline-block"></div>};
<a name="line1605"></a><div class="linenumber">1605</div>
<a name="line1606"></a><div class="linenumber">1606</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1607"></a><div class="linenumber">1607</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;whether&nbsp;WebRTC&nbsp;data&nbsp;channels&nbsp;are&nbsp;used&nbsp;to&nbsp;send&nbsp;inter-client&nbsp;messages.
<a name="line1608"></a><div class="linenumber">1608</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;is&nbsp;only&nbsp;the&nbsp;messages&nbsp;that&nbsp;applications&nbsp;explicitly&nbsp;send&nbsp;to&nbsp;other&nbsp;applications,&nbsp;not&nbsp;the&nbsp;WebRTC&nbsp;signaling&nbsp;messages.
<a name="line1609"></a><div class="linenumber">1609</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enabled&nbsp;&nbsp;true&nbsp;to&nbsp;use&nbsp;data&nbsp;channels,&nbsp;false&nbsp;otherwise.&nbsp;The&nbsp;default&nbsp;is&nbsp;false.
<a name="line1610"></a><div class="linenumber">1610</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1611"></a><div class="linenumber">1611</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.enableDataChannels(true);
<a name="line1612"></a><div class="linenumber">1612</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1613"></a><div class="linenumber">1613</div><div style="width:2em;display:inline-block"></div>this.enableDataChannels&nbsp;=&nbsp;function(enabled)&nbsp;{
<a name="line1614"></a><div class="linenumber">1614</div><div style="width:4em;display:inline-block"></div>dataEnabled&nbsp;=&nbsp;enabled;
<a name="line1615"></a><div class="linenumber">1615</div><div style="width:2em;display:inline-block"></div>};
<a name="line1616"></a><div class="linenumber">1616</div>
<a name="line1617"></a><div class="linenumber">1617</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1618"></a><div class="linenumber">1618</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line1619"></a><div class="linenumber">1619</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enable
<a name="line1620"></a><div class="linenumber">1620</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Array}&nbsp;tracks&nbsp;-&nbsp;an&nbsp;array&nbsp;of&nbsp;MediaStreamTrack
<a name="line1621"></a><div class="linenumber">1621</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1622"></a><div class="linenumber">1622</div><div style="width:2em;display:inline-block"></div>function&nbsp;enableMediaTracks(enable,&nbsp;tracks)&nbsp;{
<a name="line1623"></a><div class="linenumber">1623</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line1624"></a><div class="linenumber">1624</div><div style="width:4em;display:inline-block"></div>if&nbsp;(tracks)&nbsp;{
<a name="line1625"></a><div class="linenumber">1625</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;tracks.length;&nbsp;i++)&nbsp;{
<a name="line1626"></a><div class="linenumber">1626</div><div style="width:8em;display:inline-block"></div>var&nbsp;track&nbsp;=&nbsp;tracks[i];
<a name="line1627"></a><div class="linenumber">1627</div><div style="width:8em;display:inline-block"></div>track.enabled&nbsp;=&nbsp;enable;
<a name="line1628"></a><div class="linenumber">1628</div><div style="width:6em;display:inline-block"></div>}
<a name="line1629"></a><div class="linenumber">1629</div><div style="width:4em;display:inline-block"></div>}
<a name="line1630"></a><div class="linenumber">1630</div><div style="width:2em;display:inline-block"></div>}
<a name="line1631"></a><div class="linenumber">1631</div>
<a name="line1632"></a><div class="linenumber">1632</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line1633"></a><div class="linenumber">1633</div><div style="width:2em;display:inline-block"></div>//
<a name="line1634"></a><div class="linenumber">1634</div><div style="width:2em;display:inline-block"></div>//&nbsp;fetches&nbsp;a&nbsp;stream&nbsp;by&nbsp;name.&nbsp;Treat&nbsp;a&nbsp;null/undefined&nbsp;streamName&nbsp;as&nbsp;"default".
<a name="line1635"></a><div class="linenumber">1635</div><div style="width:2em;display:inline-block"></div>//
<a name="line1636"></a><div class="linenumber">1636</div><div style="width:2em;display:inline-block"></div>function&nbsp;getLocalMediaStreamByName(streamName)&nbsp;{
<a name="line1637"></a><div class="linenumber">1637</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamName)&nbsp;{
<a name="line1638"></a><div class="linenumber">1638</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;"default";
<a name="line1639"></a><div class="linenumber">1639</div><div style="width:4em;display:inline-block"></div>}
<a name="line1640"></a><div class="linenumber">1640</div><div style="width:4em;display:inline-block"></div>if&nbsp;(namedLocalMediaStreams.hasOwnProperty(streamName))&nbsp;{
<a name="line1641"></a><div class="linenumber">1641</div><div style="width:6em;display:inline-block"></div>return&nbsp;namedLocalMediaStreams[streamName];
<a name="line1642"></a><div class="linenumber">1642</div><div style="width:4em;display:inline-block"></div>}
<a name="line1643"></a><div class="linenumber">1643</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1644"></a><div class="linenumber">1644</div><div style="width:6em;display:inline-block"></div>return&nbsp;null;
<a name="line1645"></a><div class="linenumber">1645</div><div style="width:4em;display:inline-block"></div>}
<a name="line1646"></a><div class="linenumber">1646</div><div style="width:2em;display:inline-block"></div>}
<a name="line1647"></a><div class="linenumber">1647</div>
<a name="line1648"></a><div class="linenumber">1648</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1649"></a><div class="linenumber">1649</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;the&nbsp;user&nbsp;assigned&nbsp;id's&nbsp;of&nbsp;currently&nbsp;active&nbsp;local&nbsp;media&nbsp;streams.
<a name="line1650"></a><div class="linenumber">1650</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Array}
<a name="line1651"></a><div class="linenumber">1651</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1652"></a><div class="linenumber">1652</div><div style="width:2em;display:inline-block"></div>this.getLocalMediaIds&nbsp;=&nbsp;function()&nbsp;{
<a name="line1653"></a><div class="linenumber">1653</div><div style="width:4em;display:inline-block"></div>return&nbsp;Object.keys(namedLocalMediaStreams);
<a name="line1654"></a><div class="linenumber">1654</div><div style="width:2em;display:inline-block"></div>};
<a name="line1655"></a><div class="linenumber">1655</div>
<a name="line1656"></a><div class="linenumber">1656</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line1657"></a><div class="linenumber">1657</div><div style="width:2em;display:inline-block"></div>function&nbsp;buildMediaIds()&nbsp;{
<a name="line1658"></a><div class="linenumber">1658</div><div style="width:4em;display:inline-block"></div>var&nbsp;mediaMap&nbsp;=&nbsp;{};
<a name="line1659"></a><div class="linenumber">1659</div><div style="width:4em;display:inline-block"></div>var&nbsp;streamName;
<a name="line1660"></a><div class="linenumber">1660</div><div style="width:4em;display:inline-block"></div>for&nbsp;(streamName&nbsp;in&nbsp;namedLocalMediaStreams)&nbsp;{
<a name="line1661"></a><div class="linenumber">1661</div><div style="width:6em;display:inline-block"></div>if&nbsp;(namedLocalMediaStreams.hasOwnProperty(streamName))&nbsp;{
<a name="line1662"></a><div class="linenumber">1662</div><div style="width:8em;display:inline-block"></div>mediaMap[streamName]&nbsp;=&nbsp;namedLocalMediaStreams[streamName].id&nbsp;||&nbsp;"default";
<a name="line1663"></a><div class="linenumber">1663</div><div style="width:6em;display:inline-block"></div>}
<a name="line1664"></a><div class="linenumber">1664</div><div style="width:4em;display:inline-block"></div>}
<a name="line1665"></a><div class="linenumber">1665</div><div style="width:4em;display:inline-block"></div>return&nbsp;mediaMap;
<a name="line1666"></a><div class="linenumber">1666</div><div style="width:2em;display:inline-block"></div>}
<a name="line1667"></a><div class="linenumber">1667</div>
<a name="line1668"></a><div class="linenumber">1668</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line1669"></a><div class="linenumber">1669</div><div style="width:2em;display:inline-block"></div>function&nbsp;registerLocalMediaStreamByName(stream,&nbsp;streamName)&nbsp;{
<a name="line1670"></a><div class="linenumber">1670</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomName;
<a name="line1671"></a><div class="linenumber">1671</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamName)&nbsp;{
<a name="line1672"></a><div class="linenumber">1672</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;"default";
<a name="line1673"></a><div class="linenumber">1673</div><div style="width:4em;display:inline-block"></div>}
<a name="line1674"></a><div class="linenumber">1674</div><div style="width:4em;display:inline-block"></div>stream.streamName&nbsp;=&nbsp;streamName;
<a name="line1675"></a><div class="linenumber">1675</div><div style="width:4em;display:inline-block"></div>namedLocalMediaStreams[streamName]&nbsp;=&nbsp;stream;
<a name="line1676"></a><div class="linenumber">1676</div><div style="width:4em;display:inline-block"></div>if&nbsp;(streamName&nbsp;!==&nbsp;"default")&nbsp;{
<a name="line1677"></a><div class="linenumber">1677</div><div style="width:6em;display:inline-block"></div>var&nbsp;mediaIds&nbsp;=&nbsp;buildMediaIds(),
<a name="line1678"></a><div class="linenumber">1678</div><div style="width:8em;display:inline-block"></div>roomData&nbsp;=&nbsp;self.roomData;
<a name="line1679"></a><div class="linenumber">1679</div><div style="width:6em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;roomData)&nbsp;{
<a name="line1680"></a><div class="linenumber">1680</div><div style="width:8em;display:inline-block"></div>if&nbsp;(roomData.hasOwnProperty(roomName))&nbsp;{
<a name="line1681"></a><div class="linenumber">1681</div><div style="width:10em;display:inline-block"></div>self.setRoomApiField(roomName,&nbsp;"mediaIds",&nbsp;mediaIds);
<a name="line1682"></a><div class="linenumber">1682</div><div style="width:8em;display:inline-block"></div>}
<a name="line1683"></a><div class="linenumber">1683</div><div style="width:6em;display:inline-block"></div>}
<a name="line1684"></a><div class="linenumber">1684</div><div style="width:4em;display:inline-block"></div>}
<a name="line1685"></a><div class="linenumber">1685</div><div style="width:2em;display:inline-block"></div>}
<a name="line1686"></a><div class="linenumber">1686</div>
<a name="line1687"></a><div class="linenumber">1687</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1688"></a><div class="linenumber">1688</div><div style="width:2em;display:inline-block"></div>*&nbsp;Allow&nbsp;an&nbsp;externally&nbsp;created&nbsp;mediastream&nbsp;(ie,&nbsp;created&nbsp;by&nbsp;another
<a name="line1689"></a><div class="linenumber">1689</div><div style="width:2em;display:inline-block"></div>*&nbsp;library)&nbsp;to&nbsp;be&nbsp;used&nbsp;within&nbsp;easyrtc.&nbsp;Tracking&nbsp;when&nbsp;it&nbsp;closes
<a name="line1690"></a><div class="linenumber">1690</div><div style="width:2em;display:inline-block"></div>*&nbsp;must&nbsp;be&nbsp;done&nbsp;by&nbsp;the&nbsp;supplying&nbsp;party.
<a name="line1691"></a><div class="linenumber">1691</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1692"></a><div class="linenumber">1692</div><div style="width:2em;display:inline-block"></div>this.register3rdPartyLocalMediaStream&nbsp;=&nbsp;function(stream,&nbsp;streamName)&nbsp;{
<a name="line1693"></a><div class="linenumber">1693</div><div style="width:3em;display:inline-block"></div>return&nbsp;registerLocalMediaStreamByName(stream,&nbsp;streamName);
<a name="line1694"></a><div class="linenumber">1694</div><div style="width:2em;display:inline-block"></div>};
<a name="line1695"></a><div class="linenumber">1695</div>
<a name="line1696"></a><div class="linenumber">1696</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line1697"></a><div class="linenumber">1697</div><div style="width:2em;display:inline-block"></div>//
<a name="line1698"></a><div class="linenumber">1698</div><div style="width:2em;display:inline-block"></div>//&nbsp;look&nbsp;up&nbsp;a&nbsp;stream's&nbsp;name&nbsp;from&nbsp;the&nbsp;stream.id
<a name="line1699"></a><div class="linenumber">1699</div><div style="width:2em;display:inline-block"></div>//
<a name="line1700"></a><div class="linenumber">1700</div><div style="width:2em;display:inline-block"></div>function&nbsp;getNameOfRemoteStream(easyrtcId,&nbsp;webrtcStreamId)&nbsp;{
<a name="line1701"></a><div class="linenumber">1701</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomName;
<a name="line1702"></a><div class="linenumber">1702</div><div style="width:4em;display:inline-block"></div>var&nbsp;mediaIds;
<a name="line1703"></a><div class="linenumber">1703</div><div style="width:4em;display:inline-block"></div>var&nbsp;streamName;
<a name="line1704"></a><div class="linenumber">1704</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!webrtcStreamId)&nbsp;{
<a name="line1705"></a><div class="linenumber">1705</div><div style="width:6em;display:inline-block"></div>webrtcStreamId&nbsp;=&nbsp;"default";
<a name="line1706"></a><div class="linenumber">1706</div><div style="width:4em;display:inline-block"></div>}
<a name="line1707"></a><div class="linenumber">1707</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[easyrtcId])&nbsp;{
<a name="line1708"></a><div class="linenumber">1708</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;peerConns[easyrtcId].remoteStreamIdToName[webrtcStreamId];
<a name="line1709"></a><div class="linenumber">1709</div><div style="width:6em;display:inline-block"></div>if&nbsp;(streamName)&nbsp;{
<a name="line1710"></a><div class="linenumber">1710</div><div style="width:8em;display:inline-block"></div>return&nbsp;streamName;
<a name="line1711"></a><div class="linenumber">1711</div><div style="width:6em;display:inline-block"></div>}
<a name="line1712"></a><div class="linenumber">1712</div><div style="width:4em;display:inline-block"></div>}
<a name="line1713"></a><div class="linenumber">1713</div>
<a name="line1714"></a><div class="linenumber">1714</div><div style="width:4em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;self.roomData)&nbsp;{
<a name="line1715"></a><div class="linenumber">1715</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.roomData.hasOwnProperty(roomName))&nbsp;{
<a name="line1716"></a><div class="linenumber">1716</div><div style="width:8em;display:inline-block"></div>mediaIds&nbsp;=&nbsp;self.getRoomApiField(roomName,&nbsp;easyrtcId,&nbsp;"mediaIds");
<a name="line1717"></a><div class="linenumber">1717</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!mediaIds)&nbsp;{
<a name="line1718"></a><div class="linenumber">1718</div><div style="width:10em;display:inline-block"></div>continue;
<a name="line1719"></a><div class="linenumber">1719</div><div style="width:8em;display:inline-block"></div>}
<a name="line1720"></a><div class="linenumber">1720</div><div style="width:8em;display:inline-block"></div>for&nbsp;(streamName&nbsp;in&nbsp;mediaIds)&nbsp;{
<a name="line1721"></a><div class="linenumber">1721</div><div style="width:10em;display:inline-block"></div>if&nbsp;(mediaIds.hasOwnProperty(streamName)&nbsp;&amp;&amp;
<a name="line1722"></a><div class="linenumber">1722</div><div style="width:14em;display:inline-block"></div>mediaIds[streamName]&nbsp;===&nbsp;webrtcStreamId)&nbsp;{
<a name="line1723"></a><div class="linenumber">1723</div><div style="width:12em;display:inline-block"></div>return&nbsp;streamName;
<a name="line1724"></a><div class="linenumber">1724</div><div style="width:10em;display:inline-block"></div>}
<a name="line1725"></a><div class="linenumber">1725</div><div style="width:8em;display:inline-block"></div>}
<a name="line1726"></a><div class="linenumber">1726</div><div style="width:8em;display:inline-block"></div>//
<a name="line1727"></a><div class="linenumber">1727</div><div style="width:8em;display:inline-block"></div>//&nbsp;a&nbsp;stream&nbsp;from&nbsp;chrome&nbsp;to&nbsp;firefox&nbsp;will&nbsp;be&nbsp;missing&nbsp;it's&nbsp;id/label.
<a name="line1728"></a><div class="linenumber">1728</div><div style="width:8em;display:inline-block"></div>//&nbsp;there&nbsp;is&nbsp;no&nbsp;correct&nbsp;solution.
<a name="line1729"></a><div class="linenumber">1729</div><div style="width:8em;display:inline-block"></div>//
<a name="line1730"></a><div class="linenumber">1730</div><div style="width:8em;display:inline-block"></div>if&nbsp;(
<a name="line1731"></a><div class="linenumber">1731</div><div style="width:10em;display:inline-block"></div>adapter&nbsp;&amp;&amp;&nbsp;adapter.browserDetails&nbsp;&amp;&amp;
<a name="line1732"></a><div class="linenumber">1732</div><div style="width:12em;display:inline-block"></div>adapter.browserDetails.browser&nbsp;===&nbsp;"firefox"
<a name="line1733"></a><div class="linenumber">1733</div><div style="width:8em;display:inline-block"></div>)&nbsp;{
<a name="line1734"></a><div class="linenumber">1734</div>
<a name="line1735"></a><div class="linenumber">1735</div><div style="width:9em;display:inline-block"></div>//&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;stream&nbsp;called&nbsp;default,&nbsp;return&nbsp;it&nbsp;in&nbsp;preference
<a name="line1736"></a><div class="linenumber">1736</div><div style="width:9em;display:inline-block"></div>if&nbsp;(mediaIds["default"])&nbsp;{
<a name="line1737"></a><div class="linenumber">1737</div><div style="width:11em;display:inline-block"></div>return&nbsp;"default";
<a name="line1738"></a><div class="linenumber">1738</div><div style="width:9em;display:inline-block"></div>}
<a name="line1739"></a><div class="linenumber">1739</div>
<a name="line1740"></a><div class="linenumber">1740</div><div style="width:9em;display:inline-block"></div>//
<a name="line1741"></a><div class="linenumber">1741</div><div style="width:9em;display:inline-block"></div>//&nbsp;otherwise&nbsp;return&nbsp;the&nbsp;first&nbsp;name&nbsp;we&nbsp;find.&nbsp;If&nbsp;there&nbsp;is&nbsp;more&nbsp;than
<a name="line1742"></a><div class="linenumber">1742</div><div style="width:9em;display:inline-block"></div>//&nbsp;one,&nbsp;complain&nbsp;to&nbsp;Mozilla.
<a name="line1743"></a><div class="linenumber">1743</div><div style="width:9em;display:inline-block"></div>//
<a name="line1744"></a><div class="linenumber">1744</div><div style="width:9em;display:inline-block"></div>for(var&nbsp;anyName&nbsp;in&nbsp;mediaIds)&nbsp;{
<a name="line1745"></a><div class="linenumber">1745</div><div style="width:12em;display:inline-block"></div>if&nbsp;(mediaIds.hasOwnProperty(anyName))&nbsp;{
<a name="line1746"></a><div class="linenumber">1746</div><div style="width:14em;display:inline-block"></div>return&nbsp;anyName;
<a name="line1747"></a><div class="linenumber">1747</div><div style="width:12em;display:inline-block"></div>}
<a name="line1748"></a><div class="linenumber">1748</div><div style="width:9em;display:inline-block"></div>}
<a name="line1749"></a><div class="linenumber">1749</div><div style="width:8em;display:inline-block"></div>}
<a name="line1750"></a><div class="linenumber">1750</div><div style="width:6em;display:inline-block"></div>}
<a name="line1751"></a><div class="linenumber">1751</div><div style="width:4em;display:inline-block"></div>}
<a name="line1752"></a><div class="linenumber">1752</div>
<a name="line1753"></a><div class="linenumber">1753</div><div style="width:4em;display:inline-block"></div>return&nbsp;undefined;
<a name="line1754"></a><div class="linenumber">1754</div><div style="width:2em;display:inline-block"></div>}
<a name="line1755"></a><div class="linenumber">1755</div>
<a name="line1756"></a><div class="linenumber">1756</div><div style="width:2em;display:inline-block"></div>this.getNameOfRemoteStream&nbsp;=&nbsp;function(easyrtcId,&nbsp;webrtcStream){
<a name="line1757"></a><div class="linenumber">1757</div><div style="width:4em;display:inline-block"></div>if(typeof&nbsp;webrtcStream&nbsp;===&nbsp;"string")&nbsp;{
<a name="line1758"></a><div class="linenumber">1758</div><div style="width:6em;display:inline-block"></div>return&nbsp;getNameOfRemoteStream(easyrtcId,&nbsp;webrtcStream);
<a name="line1759"></a><div class="linenumber">1759</div><div style="width:4em;display:inline-block"></div>}
<a name="line1760"></a><div class="linenumber">1760</div><div style="width:4em;display:inline-block"></div>else&nbsp;if(&nbsp;webrtcStream.id)&nbsp;{
<a name="line1761"></a><div class="linenumber">1761</div><div style="width:6em;display:inline-block"></div>return&nbsp;getNameOfRemoteStream(easyrtcId,&nbsp;webrtcStream.id);
<a name="line1762"></a><div class="linenumber">1762</div><div style="width:4em;display:inline-block"></div>}
<a name="line1763"></a><div class="linenumber">1763</div><div style="width:2em;display:inline-block"></div>};
<a name="line1764"></a><div class="linenumber">1764</div>
<a name="line1765"></a><div class="linenumber">1765</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line1766"></a><div class="linenumber">1766</div><div style="width:2em;display:inline-block"></div>function&nbsp;closeLocalMediaStreamByName(streamName)&nbsp;{
<a name="line1767"></a><div class="linenumber">1767</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamName)&nbsp;{
<a name="line1768"></a><div class="linenumber">1768</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;"default";
<a name="line1769"></a><div class="linenumber">1769</div><div style="width:4em;display:inline-block"></div>}
<a name="line1770"></a><div class="linenumber">1770</div><div style="width:4em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;self.getLocalStream(streamName);
<a name="line1771"></a><div class="linenumber">1771</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!stream)&nbsp;{
<a name="line1772"></a><div class="linenumber">1772</div><div style="width:6em;display:inline-block"></div>return;
<a name="line1773"></a><div class="linenumber">1773</div><div style="width:4em;display:inline-block"></div>}
<a name="line1774"></a><div class="linenumber">1774</div><div style="width:4em;display:inline-block"></div>var&nbsp;streamId&nbsp;=&nbsp;stream.id&nbsp;||&nbsp;"default";
<a name="line1775"></a><div class="linenumber">1775</div><div style="width:4em;display:inline-block"></div>var&nbsp;id;
<a name="line1776"></a><div class="linenumber">1776</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomName;
<a name="line1777"></a><div class="linenumber">1777</div><div style="width:4em;display:inline-block"></div>if&nbsp;(namedLocalMediaStreams[streamName])&nbsp;{
<a name="line1778"></a><div class="linenumber">1778</div>
<a name="line1779"></a><div class="linenumber">1779</div><div style="width:6em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line1780"></a><div class="linenumber">1780</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns.hasOwnProperty(id))&nbsp;{
<a name="line1781"></a><div class="linenumber">1781</div><div style="width:10em;display:inline-block"></div>try&nbsp;{
<a name="line1782"></a><div class="linenumber">1782</div><div style="width:12em;display:inline-block"></div>peerConns[id].pc.removeStream(stream);
<a name="line1783"></a><div class="linenumber">1783</div><div style="width:10em;display:inline-block"></div>}&nbsp;catch&nbsp;(err)&nbsp;{
<a name="line1784"></a><div class="linenumber">1784</div><div style="width:10em;display:inline-block"></div>}
<a name="line1785"></a><div class="linenumber">1785</div><div style="width:10em;display:inline-block"></div>self.sendPeerMessage(id,&nbsp;"__closingMediaStream",&nbsp;{streamId:&nbsp;streamId,&nbsp;streamName:&nbsp;streamName});
<a name="line1786"></a><div class="linenumber">1786</div><div style="width:8em;display:inline-block"></div>}
<a name="line1787"></a><div class="linenumber">1787</div><div style="width:6em;display:inline-block"></div>}
<a name="line1788"></a><div class="linenumber">1788</div>
<a name="line1789"></a><div class="linenumber">1789</div><div style="width:6em;display:inline-block"></div>stopStream(namedLocalMediaStreams[streamName]);
<a name="line1790"></a><div class="linenumber">1790</div><div style="width:6em;display:inline-block"></div>delete&nbsp;namedLocalMediaStreams[streamName];
<a name="line1791"></a><div class="linenumber">1791</div>
<a name="line1792"></a><div class="linenumber">1792</div><div style="width:6em;display:inline-block"></div>if&nbsp;(streamName&nbsp;!==&nbsp;"default")&nbsp;{
<a name="line1793"></a><div class="linenumber">1793</div><div style="width:8em;display:inline-block"></div>var&nbsp;mediaIds&nbsp;=&nbsp;buildMediaIds();
<a name="line1794"></a><div class="linenumber">1794</div><div style="width:8em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;self.roomData)&nbsp;{
<a name="line1795"></a><div class="linenumber">1795</div><div style="width:10em;display:inline-block"></div>if&nbsp;(self.roomData.hasOwnProperty(roomName))&nbsp;{
<a name="line1796"></a><div class="linenumber">1796</div><div style="width:12em;display:inline-block"></div>self.setRoomApiField(roomName,&nbsp;"mediaIds",&nbsp;mediaIds);
<a name="line1797"></a><div class="linenumber">1797</div><div style="width:10em;display:inline-block"></div>}
<a name="line1798"></a><div class="linenumber">1798</div><div style="width:8em;display:inline-block"></div>}
<a name="line1799"></a><div class="linenumber">1799</div><div style="width:6em;display:inline-block"></div>}
<a name="line1800"></a><div class="linenumber">1800</div><div style="width:4em;display:inline-block"></div>}
<a name="line1801"></a><div class="linenumber">1801</div><div style="width:2em;display:inline-block"></div>}
<a name="line1802"></a><div class="linenumber">1802</div>
<a name="line1803"></a><div class="linenumber">1803</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1804"></a><div class="linenumber">1804</div><div style="width:2em;display:inline-block"></div>*&nbsp;Close&nbsp;the&nbsp;local&nbsp;media&nbsp;stream.&nbsp;You&nbsp;usually&nbsp;need&nbsp;to&nbsp;close&nbsp;the&nbsp;existing&nbsp;media&nbsp;stream
<a name="line1805"></a><div class="linenumber">1805</div><div style="width:2em;display:inline-block"></div>*&nbsp;of&nbsp;a&nbsp;camera&nbsp;before&nbsp;reacquiring&nbsp;it&nbsp;at&nbsp;a&nbsp;different&nbsp;resolution.
<a name="line1806"></a><div class="linenumber">1806</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;an&nbsp;option&nbsp;stream&nbsp;name.
<a name="line1807"></a><div class="linenumber">1807</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1808"></a><div class="linenumber">1808</div><div style="width:2em;display:inline-block"></div>this.closeLocalMediaStream&nbsp;=&nbsp;function(streamName)&nbsp;{
<a name="line1809"></a><div class="linenumber">1809</div><div style="width:4em;display:inline-block"></div>return&nbsp;closeLocalMediaStreamByName(streamName);
<a name="line1810"></a><div class="linenumber">1810</div><div style="width:2em;display:inline-block"></div>};
<a name="line1811"></a><div class="linenumber">1811</div>
<a name="line1812"></a><div class="linenumber">1812</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1813"></a><div class="linenumber">1813</div><div style="width:2em;display:inline-block"></div>*&nbsp;Alias&nbsp;for&nbsp;closeLocalMediaStream
<a name="line1814"></a><div class="linenumber">1814</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1815"></a><div class="linenumber">1815</div><div style="width:2em;display:inline-block"></div>this.closeLocalStream&nbsp;=&nbsp;this.closeLocalMediaStream;
<a name="line1816"></a><div class="linenumber">1816</div>
<a name="line1817"></a><div class="linenumber">1817</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1818"></a><div class="linenumber">1818</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;is&nbsp;used&nbsp;to&nbsp;enable&nbsp;and&nbsp;disable&nbsp;the&nbsp;local&nbsp;camera.&nbsp;If&nbsp;you&nbsp;disable&nbsp;the
<a name="line1819"></a><div class="linenumber">1819</div><div style="width:2em;display:inline-block"></div>*&nbsp;camera,&nbsp;video&nbsp;objects&nbsp;display&nbsp;it&nbsp;will&nbsp;"freeze"&nbsp;until&nbsp;the&nbsp;camera&nbsp;is&nbsp;re-enabled.&nbsp;*
<a name="line1820"></a><div class="linenumber">1820</div><div style="width:2em;display:inline-block"></div>*&nbsp;By&nbsp;default,&nbsp;a&nbsp;camera&nbsp;is&nbsp;enabled.
<a name="line1821"></a><div class="linenumber">1821</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enable&nbsp;-&nbsp;true&nbsp;to&nbsp;enable&nbsp;the&nbsp;camera,&nbsp;false&nbsp;to&nbsp;disable&nbsp;it.
<a name="line1822"></a><div class="linenumber">1822</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;stream,&nbsp;optional.
<a name="line1823"></a><div class="linenumber">1823</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1824"></a><div class="linenumber">1824</div><div style="width:2em;display:inline-block"></div>this.enableCamera&nbsp;=&nbsp;function(enable,&nbsp;streamName)&nbsp;{
<a name="line1825"></a><div class="linenumber">1825</div><div style="width:4em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;getLocalMediaStreamByName(streamName);
<a name="line1826"></a><div class="linenumber">1826</div><div style="width:4em;display:inline-block"></div>if&nbsp;(stream&nbsp;&amp;&amp;&nbsp;stream.getVideoTracks)&nbsp;{
<a name="line1827"></a><div class="linenumber">1827</div><div style="width:6em;display:inline-block"></div>enableMediaTracks(enable,&nbsp;stream.getVideoTracks());
<a name="line1828"></a><div class="linenumber">1828</div><div style="width:4em;display:inline-block"></div>}
<a name="line1829"></a><div class="linenumber">1829</div><div style="width:2em;display:inline-block"></div>};
<a name="line1830"></a><div class="linenumber">1830</div>
<a name="line1831"></a><div class="linenumber">1831</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1832"></a><div class="linenumber">1832</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;is&nbsp;used&nbsp;to&nbsp;enable&nbsp;and&nbsp;disable&nbsp;the&nbsp;local&nbsp;microphone.&nbsp;If&nbsp;you&nbsp;disable
<a name="line1833"></a><div class="linenumber">1833</div><div style="width:2em;display:inline-block"></div>*&nbsp;the&nbsp;microphone,&nbsp;sounds&nbsp;stops&nbsp;being&nbsp;transmitted&nbsp;to&nbsp;your&nbsp;peers.&nbsp;By&nbsp;default,&nbsp;the&nbsp;microphone
<a name="line1834"></a><div class="linenumber">1834</div><div style="width:2em;display:inline-block"></div>*&nbsp;is&nbsp;enabled.
<a name="line1835"></a><div class="linenumber">1835</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;enable&nbsp;-&nbsp;true&nbsp;to&nbsp;enable&nbsp;the&nbsp;microphone,&nbsp;false&nbsp;to&nbsp;disable&nbsp;it.
<a name="line1836"></a><div class="linenumber">1836</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;an&nbsp;optional&nbsp;streamName
<a name="line1837"></a><div class="linenumber">1837</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1838"></a><div class="linenumber">1838</div><div style="width:2em;display:inline-block"></div>this.enableMicrophone&nbsp;=&nbsp;function(enable,&nbsp;streamName)&nbsp;{
<a name="line1839"></a><div class="linenumber">1839</div><div style="width:4em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;getLocalMediaStreamByName(streamName);
<a name="line1840"></a><div class="linenumber">1840</div><div style="width:4em;display:inline-block"></div>if&nbsp;(stream&nbsp;&amp;&amp;&nbsp;stream.getAudioTracks)&nbsp;{
<a name="line1841"></a><div class="linenumber">1841</div><div style="width:6em;display:inline-block"></div>enableMediaTracks(enable,&nbsp;stream.getAudioTracks());
<a name="line1842"></a><div class="linenumber">1842</div><div style="width:4em;display:inline-block"></div>}
<a name="line1843"></a><div class="linenumber">1843</div><div style="width:2em;display:inline-block"></div>};
<a name="line1844"></a><div class="linenumber">1844</div>
<a name="line1845"></a><div class="linenumber">1845</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1846"></a><div class="linenumber">1846</div><div style="width:2em;display:inline-block"></div>*&nbsp;Mute&nbsp;a&nbsp;video&nbsp;object.
<a name="line1847"></a><div class="linenumber">1847</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;videoObjectName&nbsp;-&nbsp;A&nbsp;DOMObject&nbsp;or&nbsp;the&nbsp;id&nbsp;of&nbsp;the&nbsp;DOMObject.
<a name="line1848"></a><div class="linenumber">1848</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;mute&nbsp;-&nbsp;true&nbsp;to&nbsp;mute&nbsp;the&nbsp;video&nbsp;object,&nbsp;false&nbsp;to&nbsp;unmute&nbsp;it.
<a name="line1849"></a><div class="linenumber">1849</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1850"></a><div class="linenumber">1850</div><div style="width:2em;display:inline-block"></div>this.muteVideoObject&nbsp;=&nbsp;function(videoObjectName,&nbsp;mute)&nbsp;{
<a name="line1851"></a><div class="linenumber">1851</div><div style="width:4em;display:inline-block"></div>var&nbsp;videoObject;
<a name="line1852"></a><div class="linenumber">1852</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;(videoObjectName)&nbsp;===&nbsp;'string')&nbsp;{
<a name="line1853"></a><div class="linenumber">1853</div><div style="width:6em;display:inline-block"></div>videoObject&nbsp;=&nbsp;document.getElementById(videoObjectName);
<a name="line1854"></a><div class="linenumber">1854</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!videoObject)&nbsp;{
<a name="line1855"></a><div class="linenumber">1855</div><div style="width:8em;display:inline-block"></div>throw&nbsp;"Unknown&nbsp;video&nbsp;object&nbsp;"&nbsp;+&nbsp;videoObjectName;
<a name="line1856"></a><div class="linenumber">1856</div><div style="width:6em;display:inline-block"></div>}
<a name="line1857"></a><div class="linenumber">1857</div><div style="width:4em;display:inline-block"></div>}
<a name="line1858"></a><div class="linenumber">1858</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(!videoObjectName)&nbsp;{
<a name="line1859"></a><div class="linenumber">1859</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"muteVideoObject&nbsp;passed&nbsp;a&nbsp;null";
<a name="line1860"></a><div class="linenumber">1860</div><div style="width:4em;display:inline-block"></div>}
<a name="line1861"></a><div class="linenumber">1861</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1862"></a><div class="linenumber">1862</div><div style="width:6em;display:inline-block"></div>videoObject&nbsp;=&nbsp;videoObjectName;
<a name="line1863"></a><div class="linenumber">1863</div><div style="width:4em;display:inline-block"></div>}
<a name="line1864"></a><div class="linenumber">1864</div><div style="width:4em;display:inline-block"></div>videoObject.muted&nbsp;=&nbsp;!!mute;
<a name="line1865"></a><div class="linenumber">1865</div><div style="width:2em;display:inline-block"></div>};
<a name="line1866"></a><div class="linenumber">1866</div>
<a name="line1867"></a><div class="linenumber">1867</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1868"></a><div class="linenumber">1868</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;a&nbsp;URL&nbsp;for&nbsp;your&nbsp;local&nbsp;camera&nbsp;and&nbsp;microphone.
<a name="line1869"></a><div class="linenumber">1869</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;It&nbsp;can&nbsp;be&nbsp;called&nbsp;only&nbsp;after&nbsp;easyrtc.initMediaSource&nbsp;has&nbsp;succeeded.
<a name="line1870"></a><div class="linenumber">1870</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;It&nbsp;returns&nbsp;a&nbsp;url&nbsp;that&nbsp;can&nbsp;be&nbsp;used&nbsp;as&nbsp;a&nbsp;source&nbsp;by&nbsp;the&nbsp;Chrome&nbsp;video&nbsp;element&nbsp;or&nbsp;the&nbsp;&amp;lt;canvas&amp;gt;&nbsp;element.
<a name="line1871"></a><div class="linenumber">1871</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;an&nbsp;option&nbsp;stream&nbsp;name.
<a name="line1872"></a><div class="linenumber">1872</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@return&nbsp;{URL}
<a name="line1873"></a><div class="linenumber">1873</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@example
<a name="line1874"></a><div class="linenumber">1874</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById("myVideo").src&nbsp;=&nbsp;easyrtc.getLocalStreamAsUrl();
<a name="line1875"></a><div class="linenumber">1875</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1876"></a><div class="linenumber">1876</div><div style="width:2em;display:inline-block"></div>self.getLocalStreamAsUrl&nbsp;=&nbsp;function(streamName)&nbsp;{
<a name="line1877"></a><div class="linenumber">1877</div><div style="width:4em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;getLocalMediaStreamByName(streamName);
<a name="line1878"></a><div class="linenumber">1878</div><div style="width:4em;display:inline-block"></div>if&nbsp;(stream&nbsp;===&nbsp;null)&nbsp;{
<a name="line1879"></a><div class="linenumber">1879</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Developer&nbsp;error:&nbsp;attempt&nbsp;to&nbsp;get&nbsp;a&nbsp;MediaStream&nbsp;without&nbsp;invoking&nbsp;easyrtc.initMediaSource&nbsp;successfully";
<a name="line1880"></a><div class="linenumber">1880</div><div style="width:4em;display:inline-block"></div>}
<a name="line1881"></a><div class="linenumber">1881</div><div style="width:4em;display:inline-block"></div>return&nbsp;self.createObjectURL(stream);
<a name="line1882"></a><div class="linenumber">1882</div><div style="width:2em;display:inline-block"></div>};
<a name="line1883"></a><div class="linenumber">1883</div>
<a name="line1884"></a><div class="linenumber">1884</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1885"></a><div class="linenumber">1885</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;a&nbsp;media&nbsp;stream&nbsp;for&nbsp;your&nbsp;local&nbsp;camera&nbsp;and&nbsp;microphone.
<a name="line1886"></a><div class="linenumber">1886</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;It&nbsp;can&nbsp;be&nbsp;called&nbsp;only&nbsp;after&nbsp;easyrtc.initMediaSource&nbsp;has&nbsp;succeeded.
<a name="line1887"></a><div class="linenumber">1887</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;It&nbsp;returns&nbsp;a&nbsp;stream&nbsp;that&nbsp;can&nbsp;be&nbsp;used&nbsp;as&nbsp;an&nbsp;argument&nbsp;to&nbsp;easyrtc.setVideoObjectSrc.
<a name="line1888"></a><div class="linenumber">1888</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;Returns&nbsp;null&nbsp;if&nbsp;there&nbsp;is&nbsp;no&nbsp;local&nbsp;media&nbsp;stream&nbsp;acquired&nbsp;yet.
<a name="line1889"></a><div class="linenumber">1889</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{?MediaStream}
<a name="line1890"></a><div class="linenumber">1890</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1891"></a><div class="linenumber">1891</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoObjectSrc(&nbsp;document.getElementById("myVideo"),&nbsp;easyrtc.getLocalStream());
<a name="line1892"></a><div class="linenumber">1892</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1893"></a><div class="linenumber">1893</div><div style="width:2em;display:inline-block"></div>this.getLocalStream&nbsp;=&nbsp;function(streamName)&nbsp;{
<a name="line1894"></a><div class="linenumber">1894</div><div style="width:4em;display:inline-block"></div>return&nbsp;getLocalMediaStreamByName(streamName)&nbsp;||&nbsp;null;
<a name="line1895"></a><div class="linenumber">1895</div><div style="width:2em;display:inline-block"></div>};
<a name="line1896"></a><div class="linenumber">1896</div>
<a name="line1897"></a><div class="linenumber">1897</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Clears&nbsp;the&nbsp;media&nbsp;stream&nbsp;on&nbsp;a&nbsp;video&nbsp;object.
<a name="line1898"></a><div class="linenumber">1898</div><div style="width:2em;display:inline-block"></div>*
<a name="line1899"></a><div class="linenumber">1899</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;element&nbsp;the&nbsp;video&nbsp;object.
<a name="line1900"></a><div class="linenumber">1900</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1901"></a><div class="linenumber">1901</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.clearMediaStream(&nbsp;document.getElementById('selfVideo'));
<a name="line1902"></a><div class="linenumber">1902</div><div style="width:2em;display:inline-block"></div>*
<a name="line1903"></a><div class="linenumber">1903</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1904"></a><div class="linenumber">1904</div><div style="width:2em;display:inline-block"></div>this.clearMediaStream&nbsp;=&nbsp;function(element)&nbsp;{
<a name="line1905"></a><div class="linenumber">1905</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;element.src&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line1906"></a><div class="linenumber">1906</div><div style="width:6em;display:inline-block"></div>//noinspection&nbsp;JSUndefinedPropertyAssignment
<a name="line1907"></a><div class="linenumber">1907</div><div style="width:6em;display:inline-block"></div>element.src&nbsp;=&nbsp;"";
<a name="line1908"></a><div class="linenumber">1908</div><div style="width:4em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(typeof&nbsp;element.srcObject&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line1909"></a><div class="linenumber">1909</div><div style="width:6em;display:inline-block"></div>element.srcObject&nbsp;=&nbsp;"";
<a name="line1910"></a><div class="linenumber">1910</div><div style="width:4em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(typeof&nbsp;element.mozSrcObject&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line1911"></a><div class="linenumber">1911</div><div style="width:6em;display:inline-block"></div>element.mozSrcObject&nbsp;=&nbsp;null;
<a name="line1912"></a><div class="linenumber">1912</div><div style="width:4em;display:inline-block"></div>}
<a name="line1913"></a><div class="linenumber">1913</div><div style="width:2em;display:inline-block"></div>};
<a name="line1914"></a><div class="linenumber">1914</div>
<a name="line1915"></a><div class="linenumber">1915</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1916"></a><div class="linenumber">1916</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;Sets&nbsp;a&nbsp;video&nbsp;or&nbsp;audio&nbsp;object&nbsp;from&nbsp;a&nbsp;media&nbsp;stream.
<a name="line1917"></a><div class="linenumber">1917</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;Chrome&nbsp;uses&nbsp;the&nbsp;src&nbsp;attribute&nbsp;and&nbsp;expects&nbsp;a&nbsp;URL,&nbsp;while&nbsp;firefox
<a name="line1918"></a><div class="linenumber">1918</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;uses&nbsp;the&nbsp;mozSrcObject&nbsp;and&nbsp;expects&nbsp;a&nbsp;stream.&nbsp;This&nbsp;procedure&nbsp;hides
<a name="line1919"></a><div class="linenumber">1919</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;that&nbsp;from&nbsp;you.
<a name="line1920"></a><div class="linenumber">1920</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;If&nbsp;the&nbsp;media&nbsp;stream&nbsp;is&nbsp;from&nbsp;a&nbsp;local&nbsp;webcam,&nbsp;you&nbsp;may&nbsp;want&nbsp;to&nbsp;add&nbsp;the
<a name="line1921"></a><div class="linenumber">1921</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;easyrtcMirror&nbsp;class&nbsp;to&nbsp;the&nbsp;video&nbsp;object&nbsp;so&nbsp;it&nbsp;looks&nbsp;like&nbsp;a&nbsp;proper&nbsp;mirror.
<a name="line1922"></a><div class="linenumber">1922</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;The&nbsp;easyrtcMirror&nbsp;class&nbsp;is&nbsp;defined&nbsp;in&nbsp;this.css.
<a name="line1923"></a><div class="linenumber">1923</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;Which&nbsp;is&nbsp;could&nbsp;be&nbsp;added&nbsp;using&nbsp;the&nbsp;same&nbsp;path&nbsp;of&nbsp;easyrtc.js&nbsp;file&nbsp;to&nbsp;an&nbsp;HTML&nbsp;file
<a name="line1924"></a><div class="linenumber">1924</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Object}&nbsp;element&nbsp;an&nbsp;HTML5&nbsp;video&nbsp;element
<a name="line1925"></a><div class="linenumber">1925</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{MediaStream|String}&nbsp;stream&nbsp;a&nbsp;media&nbsp;stream&nbsp;as&nbsp;returned&nbsp;by&nbsp;easyrtc.getLocalStream&nbsp;or&nbsp;your&nbsp;stream&nbsp;acceptor.
<a name="line1926"></a><div class="linenumber">1926</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1927"></a><div class="linenumber">1927</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoObjectSrc(&nbsp;document.getElementById("myVideo"),&nbsp;easyrtc.getLocalStream());
<a name="line1928"></a><div class="linenumber">1928</div><div style="width:2em;display:inline-block"></div>*
<a name="line1929"></a><div class="linenumber">1929</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1930"></a><div class="linenumber">1930</div><div style="width:2em;display:inline-block"></div>this.setVideoObjectSrc&nbsp;=&nbsp;function(element,&nbsp;stream)&nbsp;{
<a name="line1931"></a><div class="linenumber">1931</div><div style="width:4em;display:inline-block"></div>if&nbsp;(stream&nbsp;&amp;&amp;&nbsp;stream&nbsp;!==&nbsp;"")&nbsp;{
<a name="line1932"></a><div class="linenumber">1932</div><div style="width:6em;display:inline-block"></div>element.autoplay&nbsp;=&nbsp;true;
<a name="line1933"></a><div class="linenumber">1933</div>
<a name="line1934"></a><div class="linenumber">1934</div><div style="width:6em;display:inline-block"></div>if&nbsp;(typeof&nbsp;element.src&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line1935"></a><div class="linenumber">1935</div><div style="width:8em;display:inline-block"></div>element.src&nbsp;=&nbsp;self.createObjectURL(stream);
<a name="line1936"></a><div class="linenumber">1936</div><div style="width:6em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(typeof&nbsp;element.srcObject&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line1937"></a><div class="linenumber">1937</div><div style="width:8em;display:inline-block"></div>element.srcObject&nbsp;=&nbsp;stream;
<a name="line1938"></a><div class="linenumber">1938</div><div style="width:6em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(typeof&nbsp;element.mozSrcObject&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line1939"></a><div class="linenumber">1939</div><div style="width:8em;display:inline-block"></div>element.mozSrcObject&nbsp;=&nbsp;self.createObjectURL(stream);
<a name="line1940"></a><div class="linenumber">1940</div><div style="width:6em;display:inline-block"></div>}
<a name="line1941"></a><div class="linenumber">1941</div><div style="width:6em;display:inline-block"></div>element.play();
<a name="line1942"></a><div class="linenumber">1942</div><div style="width:4em;display:inline-block"></div>}
<a name="line1943"></a><div class="linenumber">1943</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line1944"></a><div class="linenumber">1944</div><div style="width:6em;display:inline-block"></div>self.clearMediaStream(element);
<a name="line1945"></a><div class="linenumber">1945</div><div style="width:4em;display:inline-block"></div>}
<a name="line1946"></a><div class="linenumber">1946</div><div style="width:2em;display:inline-block"></div>};
<a name="line1947"></a><div class="linenumber">1947</div>
<a name="line1948"></a><div class="linenumber">1948</div><div style="width:2em;display:inline-block"></div>/**
<a name="line1949"></a><div class="linenumber">1949</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;builds&nbsp;a&nbsp;new&nbsp;named&nbsp;local&nbsp;media&nbsp;stream&nbsp;from&nbsp;a&nbsp;set&nbsp;of&nbsp;existing&nbsp;audio&nbsp;and&nbsp;video&nbsp;tracks&nbsp;from&nbsp;other&nbsp;media&nbsp;streams.
<a name="line1950"></a><div class="linenumber">1950</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;is&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;new&nbsp;media&nbsp;stream.
<a name="line1951"></a><div class="linenumber">1951</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Array}&nbsp;audioTracks&nbsp;is&nbsp;an&nbsp;array&nbsp;of&nbsp;MediaStreamTracks
<a name="line1952"></a><div class="linenumber">1952</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Array}&nbsp;videoTracks&nbsp;is&nbsp;an&nbsp;array&nbsp;of&nbsp;MediaStreamTracks
<a name="line1953"></a><div class="linenumber">1953</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{?MediaStream}&nbsp;the&nbsp;track&nbsp;created.
<a name="line1954"></a><div class="linenumber">1954</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line1955"></a><div class="linenumber">1955</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.buildLocalMediaStream("myComposedStream",
<a name="line1956"></a><div class="linenumber">1956</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.getLocalStream("camera1").getVideoTracks(),
<a name="line1957"></a><div class="linenumber">1957</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.getLocalStream("camera2").getAudioTracks());
<a name="line1958"></a><div class="linenumber">1958</div><div style="width:2em;display:inline-block"></div>*/
<a name="line1959"></a><div class="linenumber">1959</div><div style="width:2em;display:inline-block"></div>this.buildLocalMediaStream&nbsp;=&nbsp;function(streamName,&nbsp;audioTracks,&nbsp;videoTracks)&nbsp;{
<a name="line1960"></a><div class="linenumber">1960</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line1961"></a><div class="linenumber">1961</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;streamName&nbsp;!==&nbsp;'string')&nbsp;{
<a name="line1962"></a><div class="linenumber">1962</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,
<a name="line1963"></a><div class="linenumber">1963</div><div style="width:7em;display:inline-block"></div>"easyrtc.buildLocalMediaStream&nbsp;not&nbsp;supplied&nbsp;a&nbsp;stream&nbsp;name");
<a name="line1964"></a><div class="linenumber">1964</div><div style="width:6em;display:inline-block"></div>return&nbsp;null;
<a name="line1965"></a><div class="linenumber">1965</div><div style="width:4em;display:inline-block"></div>}
<a name="line1966"></a><div class="linenumber">1966</div>
<a name="line1967"></a><div class="linenumber">1967</div><div style="width:4em;display:inline-block"></div>var&nbsp;streamToClone&nbsp;=&nbsp;null;
<a name="line1968"></a><div class="linenumber">1968</div><div style="width:4em;display:inline-block"></div>for(var&nbsp;key&nbsp;in&nbsp;namedLocalMediaStreams&nbsp;)&nbsp;{
<a name="line1969"></a><div class="linenumber">1969</div><div style="width:6em;display:inline-block"></div>if(&nbsp;namedLocalMediaStreams.hasOwnProperty(key))&nbsp;{
<a name="line1970"></a><div class="linenumber">1970</div><div style="width:7em;display:inline-block"></div>streamToClone&nbsp;=&nbsp;namedLocalMediaStreams[key];
<a name="line1971"></a><div class="linenumber">1971</div><div style="width:7em;display:inline-block"></div>if(streamToClone)&nbsp;{
<a name="line1972"></a><div class="linenumber">1972</div><div style="width:8em;display:inline-block"></div>break;
<a name="line1973"></a><div class="linenumber">1973</div><div style="width:7em;display:inline-block"></div>}
<a name="line1974"></a><div class="linenumber">1974</div><div style="width:6em;display:inline-block"></div>}
<a name="line1975"></a><div class="linenumber">1975</div><div style="width:4em;display:inline-block"></div>}
<a name="line1976"></a><div class="linenumber">1976</div><div style="width:4em;display:inline-block"></div>if(&nbsp;!streamToClone&nbsp;)&nbsp;{
<a name="line1977"></a><div class="linenumber">1977</div><div style="width:6em;display:inline-block"></div>for(key&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line1978"></a><div class="linenumber">1978</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns.hasOwnProperty(key))&nbsp;{
<a name="line1979"></a><div class="linenumber">1979</div><div style="width:10em;display:inline-block"></div>var&nbsp;remoteStreams&nbsp;=&nbsp;peerConns[key].pc.getRemoteStreams();
<a name="line1980"></a><div class="linenumber">1980</div><div style="width:10em;display:inline-block"></div>if(&nbsp;remoteStreams&nbsp;&amp;&amp;&nbsp;remoteStreams.length&nbsp;&gt;&nbsp;0&nbsp;)&nbsp;{
<a name="line1981"></a><div class="linenumber">1981</div><div style="width:12em;display:inline-block"></div>streamToClone&nbsp;=&nbsp;remoteStreams[0];
<a name="line1982"></a><div class="linenumber">1982</div><div style="width:10em;display:inline-block"></div>}
<a name="line1983"></a><div class="linenumber">1983</div><div style="width:8em;display:inline-block"></div>}
<a name="line1984"></a><div class="linenumber">1984</div><div style="width:6em;display:inline-block"></div>}
<a name="line1985"></a><div class="linenumber">1985</div><div style="width:4em;display:inline-block"></div>}
<a name="line1986"></a><div class="linenumber">1986</div><div style="width:4em;display:inline-block"></div>if(&nbsp;!streamToClone&nbsp;){
<a name="line1987"></a><div class="linenumber">1987</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,
<a name="line1988"></a><div class="linenumber">1988</div><div style="width:6em;display:inline-block"></div>"Attempt&nbsp;to&nbsp;create&nbsp;a&nbsp;mediastream&nbsp;without&nbsp;one&nbsp;to&nbsp;clone&nbsp;from");
<a name="line1989"></a><div class="linenumber">1989</div><div style="width:6em;display:inline-block"></div>return&nbsp;null;
<a name="line1990"></a><div class="linenumber">1990</div><div style="width:4em;display:inline-block"></div>}
<a name="line1991"></a><div class="linenumber">1991</div>
<a name="line1992"></a><div class="linenumber">1992</div><div style="width:4em;display:inline-block"></div>//
<a name="line1993"></a><div class="linenumber">1993</div><div style="width:4em;display:inline-block"></div>//&nbsp;clone&nbsp;whatever&nbsp;mediastream&nbsp;we&nbsp;found,&nbsp;and&nbsp;remove&nbsp;any&nbsp;of&nbsp;it's
<a name="line1994"></a><div class="linenumber">1994</div><div style="width:4em;display:inline-block"></div>//&nbsp;tracks.
<a name="line1995"></a><div class="linenumber">1995</div><div style="width:4em;display:inline-block"></div>//
<a name="line1996"></a><div class="linenumber">1996</div><div style="width:4em;display:inline-block"></div>var&nbsp;mediaClone&nbsp;=&nbsp;streamToClone.clone();
<a name="line1997"></a><div class="linenumber">1997</div><div style="width:4em;display:inline-block"></div>var&nbsp;oldTracks&nbsp;=&nbsp;mediaClone.getTracks();
<a name="line1998"></a><div class="linenumber">1998</div>
<a name="line1999"></a><div class="linenumber">1999</div><div style="width:4em;display:inline-block"></div>if&nbsp;(audioTracks)&nbsp;{
<a name="line2000"></a><div class="linenumber">2000</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;audioTracks.length;&nbsp;i++)&nbsp;{
<a name="line2001"></a><div class="linenumber">2001</div><div style="width:8em;display:inline-block"></div>mediaClone.addTrack(audioTracks[i].clone());
<a name="line2002"></a><div class="linenumber">2002</div><div style="width:6em;display:inline-block"></div>}
<a name="line2003"></a><div class="linenumber">2003</div><div style="width:4em;display:inline-block"></div>}
<a name="line2004"></a><div class="linenumber">2004</div>
<a name="line2005"></a><div class="linenumber">2005</div><div style="width:4em;display:inline-block"></div>if&nbsp;(videoTracks)&nbsp;{
<a name="line2006"></a><div class="linenumber">2006</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;videoTracks.length;&nbsp;i++)&nbsp;{
<a name="line2007"></a><div class="linenumber">2007</div><div style="width:8em;display:inline-block"></div>mediaClone.addTrack(videoTracks[i].clone());
<a name="line2008"></a><div class="linenumber">2008</div><div style="width:6em;display:inline-block"></div>}
<a name="line2009"></a><div class="linenumber">2009</div><div style="width:4em;display:inline-block"></div>}
<a name="line2010"></a><div class="linenumber">2010</div>
<a name="line2011"></a><div class="linenumber">2011</div><div style="width:4em;display:inline-block"></div>for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;oldTracks.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line2012"></a><div class="linenumber">2012</div><div style="width:6em;display:inline-block"></div>mediaClone.removeTrack(oldTracks[i]);
<a name="line2013"></a><div class="linenumber">2013</div><div style="width:4em;display:inline-block"></div>}
<a name="line2014"></a><div class="linenumber">2014</div>
<a name="line2015"></a><div class="linenumber">2015</div><div style="width:4em;display:inline-block"></div>registerLocalMediaStreamByName(mediaClone,&nbsp;streamName);
<a name="line2016"></a><div class="linenumber">2016</div><div style="width:4em;display:inline-block"></div>return&nbsp;mediaClone;
<a name="line2017"></a><div class="linenumber">2017</div><div style="width:2em;display:inline-block"></div>};
<a name="line2018"></a><div class="linenumber">2018</div>
<a name="line2019"></a><div class="linenumber">2019</div><div style="width:2em;display:inline-block"></div>/*&nbsp;@private*/
<a name="line2020"></a><div class="linenumber">2020</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Load&nbsp;Easyrtc&nbsp;Stylesheet.
<a name="line2021"></a><div class="linenumber">2021</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;Easyrtc&nbsp;Stylesheet&nbsp;define&nbsp;easyrtcMirror&nbsp;class&nbsp;and&nbsp;some&nbsp;basic&nbsp;css&nbsp;class&nbsp;for&nbsp;using&nbsp;easyrtc.js.
<a name="line2022"></a><div class="linenumber">2022</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;That&nbsp;way,&nbsp;developers&nbsp;can&nbsp;override&nbsp;it&nbsp;or&nbsp;use&nbsp;it's&nbsp;own&nbsp;css&nbsp;file&nbsp;minified&nbsp;css&nbsp;or&nbsp;package.
<a name="line2023"></a><div class="linenumber">2023</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2024"></a><div class="linenumber">2024</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.loadStylesheet();
<a name="line2025"></a><div class="linenumber">2025</div><div style="width:2em;display:inline-block"></div>*
<a name="line2026"></a><div class="linenumber">2026</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2027"></a><div class="linenumber">2027</div><div style="width:2em;display:inline-block"></div>this.loadStylesheet&nbsp;=&nbsp;function()&nbsp;{
<a name="line2028"></a><div class="linenumber">2028</div>
<a name="line2029"></a><div class="linenumber">2029</div><div style="width:4em;display:inline-block"></div>//
<a name="line2030"></a><div class="linenumber">2030</div><div style="width:4em;display:inline-block"></div>//&nbsp;check&nbsp;to&nbsp;see&nbsp;if&nbsp;we&nbsp;already&nbsp;have&nbsp;an&nbsp;easyrtc.css&nbsp;file&nbsp;loaded
<a name="line2031"></a><div class="linenumber">2031</div><div style="width:4em;display:inline-block"></div>//&nbsp;if&nbsp;we&nbsp;do,&nbsp;we&nbsp;can&nbsp;exit&nbsp;immediately.
<a name="line2032"></a><div class="linenumber">2032</div><div style="width:4em;display:inline-block"></div>//
<a name="line2033"></a><div class="linenumber">2033</div><div style="width:4em;display:inline-block"></div>var&nbsp;links&nbsp;=&nbsp;document.getElementsByTagName("link");
<a name="line2034"></a><div class="linenumber">2034</div><div style="width:4em;display:inline-block"></div>var&nbsp;cssIndex,&nbsp;css;
<a name="line2035"></a><div class="linenumber">2035</div><div style="width:4em;display:inline-block"></div>for&nbsp;(cssIndex&nbsp;in&nbsp;links)&nbsp;{
<a name="line2036"></a><div class="linenumber">2036</div><div style="width:6em;display:inline-block"></div>if&nbsp;(links.hasOwnProperty(cssIndex))&nbsp;{
<a name="line2037"></a><div class="linenumber">2037</div><div style="width:8em;display:inline-block"></div>css&nbsp;=&nbsp;links[cssIndex];
<a name="line2038"></a><div class="linenumber">2038</div><div style="width:8em;display:inline-block"></div>if&nbsp;(css.href&nbsp;&amp;&amp;&nbsp;(css.href.match(/\/easyrtc.css/)))&nbsp;{
<a name="line2039"></a><div class="linenumber">2039</div><div style="width:10em;display:inline-block"></div>return;
<a name="line2040"></a><div class="linenumber">2040</div><div style="width:8em;display:inline-block"></div>}
<a name="line2041"></a><div class="linenumber">2041</div><div style="width:6em;display:inline-block"></div>}
<a name="line2042"></a><div class="linenumber">2042</div><div style="width:4em;display:inline-block"></div>}
<a name="line2043"></a><div class="linenumber">2043</div><div style="width:4em;display:inline-block"></div>//
<a name="line2044"></a><div class="linenumber">2044</div><div style="width:4em;display:inline-block"></div>//&nbsp;add&nbsp;the&nbsp;easyrtc.css&nbsp;file&nbsp;since&nbsp;it&nbsp;isn't&nbsp;present
<a name="line2045"></a><div class="linenumber">2045</div><div style="width:4em;display:inline-block"></div>//
<a name="line2046"></a><div class="linenumber">2046</div><div style="width:4em;display:inline-block"></div>var&nbsp;easySheet&nbsp;=&nbsp;document.createElement("link");
<a name="line2047"></a><div class="linenumber">2047</div><div style="width:4em;display:inline-block"></div>easySheet.setAttribute("rel",&nbsp;"stylesheet");
<a name="line2048"></a><div class="linenumber">2048</div><div style="width:4em;display:inline-block"></div>easySheet.setAttribute("type",&nbsp;"text/css");
<a name="line2049"></a><div class="linenumber">2049</div><div style="width:4em;display:inline-block"></div>easySheet.setAttribute("href",&nbsp;"/easyrtc/easyrtc.css");
<a name="line2050"></a><div class="linenumber">2050</div><div style="width:4em;display:inline-block"></div>var&nbsp;headSection&nbsp;=&nbsp;document.getElementsByTagName("head")[0];
<a name="line2051"></a><div class="linenumber">2051</div><div style="width:4em;display:inline-block"></div>var&nbsp;firstHead&nbsp;=&nbsp;headSection.childNodes[0];
<a name="line2052"></a><div class="linenumber">2052</div><div style="width:4em;display:inline-block"></div>headSection.insertBefore(easySheet,&nbsp;firstHead);
<a name="line2053"></a><div class="linenumber">2053</div><div style="width:2em;display:inline-block"></div>};
<a name="line2054"></a><div class="linenumber">2054</div>
<a name="line2055"></a><div class="linenumber">2055</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2056"></a><div class="linenumber">2056</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line2057"></a><div class="linenumber">2057</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;x
<a name="line2058"></a><div class="linenumber">2058</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2059"></a><div class="linenumber">2059</div><div style="width:2em;display:inline-block"></div>this.formatError&nbsp;=&nbsp;function(x)&nbsp;{
<a name="line2060"></a><div class="linenumber">2060</div><div style="width:4em;display:inline-block"></div>var&nbsp;name,&nbsp;result;
<a name="line2061"></a><div class="linenumber">2061</div><div style="width:4em;display:inline-block"></div>if&nbsp;(x&nbsp;===&nbsp;null&nbsp;||&nbsp;typeof&nbsp;x&nbsp;===&nbsp;'undefined')&nbsp;{
<a name="line2062"></a><div class="linenumber">2062</div><div style="width:6em;display:inline-block"></div>return&nbsp;"null";
<a name="line2063"></a><div class="linenumber">2063</div><div style="width:4em;display:inline-block"></div>}
<a name="line2064"></a><div class="linenumber">2064</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;x&nbsp;===&nbsp;'string')&nbsp;{
<a name="line2065"></a><div class="linenumber">2065</div><div style="width:6em;display:inline-block"></div>return&nbsp;x;
<a name="line2066"></a><div class="linenumber">2066</div><div style="width:4em;display:inline-block"></div>}
<a name="line2067"></a><div class="linenumber">2067</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(x.type&nbsp;&amp;&amp;&nbsp;x.description)&nbsp;{
<a name="line2068"></a><div class="linenumber">2068</div><div style="width:6em;display:inline-block"></div>return&nbsp;x.type&nbsp;+&nbsp;"&nbsp;:&nbsp;"&nbsp;+&nbsp;x.description;
<a name="line2069"></a><div class="linenumber">2069</div><div style="width:4em;display:inline-block"></div>}
<a name="line2070"></a><div class="linenumber">2070</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(typeof&nbsp;x&nbsp;===&nbsp;'object')&nbsp;{
<a name="line2071"></a><div class="linenumber">2071</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line2072"></a><div class="linenumber">2072</div><div style="width:8em;display:inline-block"></div>return&nbsp;JSON.stringify(x);
<a name="line2073"></a><div class="linenumber">2073</div><div style="width:6em;display:inline-block"></div>}
<a name="line2074"></a><div class="linenumber">2074</div><div style="width:6em;display:inline-block"></div>catch&nbsp;(oops)&nbsp;{
<a name="line2075"></a><div class="linenumber">2075</div><div style="width:8em;display:inline-block"></div>result&nbsp;=&nbsp;"{";
<a name="line2076"></a><div class="linenumber">2076</div><div style="width:8em;display:inline-block"></div>for&nbsp;(name&nbsp;in&nbsp;x)&nbsp;{
<a name="line2077"></a><div class="linenumber">2077</div><div style="width:10em;display:inline-block"></div>if&nbsp;(x.hasOwnProperty(name))&nbsp;{
<a name="line2078"></a><div class="linenumber">2078</div><div style="width:12em;display:inline-block"></div>if&nbsp;(typeof&nbsp;x[name]&nbsp;===&nbsp;'string')&nbsp;{
<a name="line2079"></a><div class="linenumber">2079</div><div style="width:14em;display:inline-block"></div>result&nbsp;=&nbsp;result&nbsp;+&nbsp;name&nbsp;+&nbsp;"='"&nbsp;+&nbsp;x[name]&nbsp;+&nbsp;"'&nbsp;";
<a name="line2080"></a><div class="linenumber">2080</div><div style="width:12em;display:inline-block"></div>}
<a name="line2081"></a><div class="linenumber">2081</div><div style="width:10em;display:inline-block"></div>}
<a name="line2082"></a><div class="linenumber">2082</div><div style="width:8em;display:inline-block"></div>}
<a name="line2083"></a><div class="linenumber">2083</div><div style="width:8em;display:inline-block"></div>result&nbsp;=&nbsp;result&nbsp;+&nbsp;"}";
<a name="line2084"></a><div class="linenumber">2084</div><div style="width:8em;display:inline-block"></div>return&nbsp;result;
<a name="line2085"></a><div class="linenumber">2085</div><div style="width:6em;display:inline-block"></div>}
<a name="line2086"></a><div class="linenumber">2086</div><div style="width:4em;display:inline-block"></div>}
<a name="line2087"></a><div class="linenumber">2087</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2088"></a><div class="linenumber">2088</div><div style="width:6em;display:inline-block"></div>return&nbsp;"Strange&nbsp;case";
<a name="line2089"></a><div class="linenumber">2089</div><div style="width:4em;display:inline-block"></div>}
<a name="line2090"></a><div class="linenumber">2090</div><div style="width:2em;display:inline-block"></div>};
<a name="line2091"></a><div class="linenumber">2091</div>
<a name="line2092"></a><div class="linenumber">2092</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2093"></a><div class="linenumber">2093</div><div style="width:2em;display:inline-block"></div>*&nbsp;Initializes&nbsp;your&nbsp;access&nbsp;to&nbsp;a&nbsp;local&nbsp;camera&nbsp;and&nbsp;microphone.
<a name="line2094"></a><div class="linenumber">2094</div><div style="width:2em;display:inline-block"></div>*&nbsp;Failure&nbsp;could&nbsp;be&nbsp;caused&nbsp;a&nbsp;browser&nbsp;that&nbsp;didn't&nbsp;support&nbsp;WebRTC,&nbsp;or&nbsp;by&nbsp;the&nbsp;user&nbsp;not&nbsp;granting&nbsp;permission.
<a name="line2095"></a><div class="linenumber">2095</div><div style="width:2em;display:inline-block"></div>*&nbsp;If&nbsp;you&nbsp;are&nbsp;going&nbsp;to&nbsp;call&nbsp;easyrtc.enableAudio&nbsp;or&nbsp;easyrtc.enableVideo,&nbsp;you&nbsp;need&nbsp;to&nbsp;do&nbsp;it&nbsp;before
<a name="line2096"></a><div class="linenumber">2096</div><div style="width:2em;display:inline-block"></div>*&nbsp;calling&nbsp;easyrtc.initMediaSource.
<a name="line2097"></a><div class="linenumber">2097</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(Object)}&nbsp;successCallback&nbsp;-&nbsp;will&nbsp;be&nbsp;called&nbsp;with&nbsp;localmedia&nbsp;stream&nbsp;on&nbsp;success.
<a name="line2098"></a><div class="linenumber">2098</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(String,String)}&nbsp;errorCallback&nbsp;-&nbsp;is&nbsp;called&nbsp;with&nbsp;an&nbsp;error&nbsp;code&nbsp;and&nbsp;error&nbsp;description.
<a name="line2099"></a><div class="linenumber">2099</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;an&nbsp;optional&nbsp;name&nbsp;for&nbsp;the&nbsp;media&nbsp;source&nbsp;so&nbsp;you&nbsp;can&nbsp;use&nbsp;multiple&nbsp;cameras&nbsp;and
<a name="line2100"></a><div class="linenumber">2100</div><div style="width:2em;display:inline-block"></div>*&nbsp;screen&nbsp;share&nbsp;simultaneously.
<a name="line2101"></a><div class="linenumber">2101</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2102"></a><div class="linenumber">2102</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.initMediaSource(
<a name="line2103"></a><div class="linenumber">2103</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(mediastream){
<a name="line2104"></a><div class="linenumber">2104</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoObjectSrc(&nbsp;document.getElementById("mirrorVideo"),&nbsp;mediastream);
<a name="line2105"></a><div class="linenumber">2105</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line2106"></a><div class="linenumber">2106</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorCode,&nbsp;errorText){
<a name="line2107"></a><div class="linenumber">2107</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.showError(errorCode,&nbsp;errorText);
<a name="line2108"></a><div class="linenumber">2108</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2109"></a><div class="linenumber">2109</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2110"></a><div class="linenumber">2110</div><div style="width:2em;display:inline-block"></div>this.initMediaSource&nbsp;=&nbsp;function(successCallback,&nbsp;errorCallback,&nbsp;streamName)&nbsp;{
<a name="line2111"></a><div class="linenumber">2111</div>
<a name="line2112"></a><div class="linenumber">2112</div><div style="width:4em;display:inline-block"></div>logDebug("about&nbsp;to&nbsp;request&nbsp;local&nbsp;media");
<a name="line2113"></a><div class="linenumber">2113</div>
<a name="line2114"></a><div class="linenumber">2114</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamName)&nbsp;{
<a name="line2115"></a><div class="linenumber">2115</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;"default";
<a name="line2116"></a><div class="linenumber">2116</div><div style="width:4em;display:inline-block"></div>}
<a name="line2117"></a><div class="linenumber">2117</div>
<a name="line2118"></a><div class="linenumber">2118</div><div style="width:4em;display:inline-block"></div>haveAudioVideo&nbsp;=&nbsp;{
<a name="line2119"></a><div class="linenumber">2119</div><div style="width:6em;display:inline-block"></div>audio:&nbsp;self.audioEnabled,
<a name="line2120"></a><div class="linenumber">2120</div><div style="width:6em;display:inline-block"></div>video:&nbsp;self.videoEnabled
<a name="line2121"></a><div class="linenumber">2121</div><div style="width:4em;display:inline-block"></div>};
<a name="line2122"></a><div class="linenumber">2122</div>
<a name="line2123"></a><div class="linenumber">2123</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!errorCallback)&nbsp;{
<a name="line2124"></a><div class="linenumber">2124</div><div style="width:6em;display:inline-block"></div>errorCallback&nbsp;=&nbsp;function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line2125"></a><div class="linenumber">2125</div><div style="width:8em;display:inline-block"></div>var&nbsp;message&nbsp;=&nbsp;"easyrtc.initMediaSource:&nbsp;"&nbsp;+&nbsp;self.formatError(errorText);
<a name="line2126"></a><div class="linenumber">2126</div><div style="width:8em;display:inline-block"></div>logDebug(message);
<a name="line2127"></a><div class="linenumber">2127</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.MEDIA_ERR,&nbsp;message);
<a name="line2128"></a><div class="linenumber">2128</div><div style="width:6em;display:inline-block"></div>};
<a name="line2129"></a><div class="linenumber">2129</div><div style="width:4em;display:inline-block"></div>}
<a name="line2130"></a><div class="linenumber">2130</div>
<a name="line2131"></a><div class="linenumber">2131</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.supportsGetUserMedia())&nbsp;{
<a name="line2132"></a><div class="linenumber">2132</div><div style="width:6em;display:inline-block"></div>errorCallback(self.errCodes.MEDIA_ERR,&nbsp;self.getConstantString("noWebrtcSupport"));
<a name="line2133"></a><div class="linenumber">2133</div><div style="width:6em;display:inline-block"></div>return;
<a name="line2134"></a><div class="linenumber">2134</div><div style="width:4em;display:inline-block"></div>}
<a name="line2135"></a><div class="linenumber">2135</div>
<a name="line2136"></a><div class="linenumber">2136</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!successCallback)&nbsp;{
<a name="line2137"></a><div class="linenumber">2137</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,
<a name="line2138"></a><div class="linenumber">2138</div><div style="width:10em;display:inline-block"></div>"easyrtc.initMediaSource&nbsp;not&nbsp;supplied&nbsp;a&nbsp;successCallback");
<a name="line2139"></a><div class="linenumber">2139</div><div style="width:6em;display:inline-block"></div>return;
<a name="line2140"></a><div class="linenumber">2140</div><div style="width:4em;display:inline-block"></div>}
<a name="line2141"></a><div class="linenumber">2141</div>
<a name="line2142"></a><div class="linenumber">2142</div><div style="width:4em;display:inline-block"></div>var&nbsp;mode&nbsp;=&nbsp;self.getUserMediaConstraints();
<a name="line2143"></a><div class="linenumber">2143</div><div style="width:4em;display:inline-block"></div>/**&nbsp;@private
<a name="line2144"></a><div class="linenumber">2144</div><div style="width:4em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;stream&nbsp;-&nbsp;A&nbsp;mediaStream&nbsp;object.
<a name="line2145"></a><div class="linenumber">2145</div><div style="width:4em;display:inline-block"></div>*&nbsp;&nbsp;*/
<a name="line2146"></a><div class="linenumber">2146</div><div style="width:4em;display:inline-block"></div>var&nbsp;onUserMediaSuccess&nbsp;=&nbsp;function(stream)&nbsp;{
<a name="line2147"></a><div class="linenumber">2147</div><div style="width:6em;display:inline-block"></div>logDebug("getUserMedia&nbsp;success&nbsp;callback&nbsp;entered");
<a name="line2148"></a><div class="linenumber">2148</div><div style="width:6em;display:inline-block"></div>logDebug("successfully&nbsp;got&nbsp;local&nbsp;media");
<a name="line2149"></a><div class="linenumber">2149</div>
<a name="line2150"></a><div class="linenumber">2150</div><div style="width:6em;display:inline-block"></div>stream.streamName&nbsp;=&nbsp;streamName;
<a name="line2151"></a><div class="linenumber">2151</div><div style="width:6em;display:inline-block"></div>registerLocalMediaStreamByName(stream,&nbsp;streamName);
<a name="line2152"></a><div class="linenumber">2152</div><div style="width:6em;display:inline-block"></div>var&nbsp;videoObj,&nbsp;triesLeft,&nbsp;tryToGetSize,&nbsp;ele;
<a name="line2153"></a><div class="linenumber">2153</div><div style="width:6em;display:inline-block"></div>if&nbsp;(haveAudioVideo.video)&nbsp;{
<a name="line2154"></a><div class="linenumber">2154</div><div style="width:8em;display:inline-block"></div>videoObj&nbsp;=&nbsp;document.createElement('video');
<a name="line2155"></a><div class="linenumber">2155</div><div style="width:8em;display:inline-block"></div>videoObj.muted&nbsp;=&nbsp;true;
<a name="line2156"></a><div class="linenumber">2156</div><div style="width:8em;display:inline-block"></div>triesLeft&nbsp;=&nbsp;30;
<a name="line2157"></a><div class="linenumber">2157</div><div style="width:8em;display:inline-block"></div>tryToGetSize&nbsp;=&nbsp;function()&nbsp;{
<a name="line2158"></a><div class="linenumber">2158</div><div style="width:10em;display:inline-block"></div>if&nbsp;(videoObj.videoWidth&nbsp;&gt;&nbsp;0&nbsp;||&nbsp;triesLeft&nbsp;&lt;&nbsp;0)&nbsp;{
<a name="line2159"></a><div class="linenumber">2159</div><div style="width:12em;display:inline-block"></div>self.nativeVideoWidth&nbsp;=&nbsp;videoObj.videoWidth;
<a name="line2160"></a><div class="linenumber">2160</div><div style="width:12em;display:inline-block"></div>self.nativeVideoHeight&nbsp;=&nbsp;videoObj.videoHeight;
<a name="line2161"></a><div class="linenumber">2161</div><div style="width:12em;display:inline-block"></div>if&nbsp;(self._desiredVideoProperties.height&nbsp;&amp;&amp;
<a name="line2162"></a><div class="linenumber">2162</div><div style="width:16em;display:inline-block"></div>(self.nativeVideoHeight&nbsp;!==&nbsp;self._desiredVideoProperties.height&nbsp;||
<a name="line2163"></a><div class="linenumber">2163</div><div style="width:20em;display:inline-block"></div>self.nativeVideoWidth&nbsp;!==&nbsp;self._desiredVideoProperties.width))&nbsp;{
<a name="line2164"></a><div class="linenumber">2164</div><div style="width:14em;display:inline-block"></div>self.showError(self.errCodes.MEDIA_WARNING,
<a name="line2165"></a><div class="linenumber">2165</div><div style="width:18em;display:inline-block"></div>self.format(self.getConstantString("resolutionWarning"),
<a name="line2166"></a><div class="linenumber">2166</div><div style="width:18em;display:inline-block"></div>self._desiredVideoProperties.width,&nbsp;self._desiredVideoProperties.height,
<a name="line2167"></a><div class="linenumber">2167</div><div style="width:18em;display:inline-block"></div>self.nativeVideoWidth,&nbsp;self.nativeVideoHeight));
<a name="line2168"></a><div class="linenumber">2168</div><div style="width:12em;display:inline-block"></div>}
<a name="line2169"></a><div class="linenumber">2169</div><div style="width:12em;display:inline-block"></div>self.setVideoObjectSrc(videoObj,&nbsp;null);
<a name="line2170"></a><div class="linenumber">2170</div><div style="width:12em;display:inline-block"></div>if&nbsp;(videoObj.removeNode)&nbsp;{
<a name="line2171"></a><div class="linenumber">2171</div><div style="width:14em;display:inline-block"></div>videoObj.removeNode(true);
<a name="line2172"></a><div class="linenumber">2172</div><div style="width:12em;display:inline-block"></div>}
<a name="line2173"></a><div class="linenumber">2173</div><div style="width:12em;display:inline-block"></div>else&nbsp;{
<a name="line2174"></a><div class="linenumber">2174</div><div style="width:14em;display:inline-block"></div>ele&nbsp;=&nbsp;document.createElement('div');
<a name="line2175"></a><div class="linenumber">2175</div><div style="width:14em;display:inline-block"></div>ele.appendChild(videoObj);
<a name="line2176"></a><div class="linenumber">2176</div><div style="width:14em;display:inline-block"></div>ele.removeChild(videoObj);
<a name="line2177"></a><div class="linenumber">2177</div><div style="width:12em;display:inline-block"></div>}
<a name="line2178"></a><div class="linenumber">2178</div>
<a name="line2179"></a><div class="linenumber">2179</div><div style="width:12em;display:inline-block"></div>updateConfigurationInfo();
<a name="line2180"></a><div class="linenumber">2180</div><div style="width:12em;display:inline-block"></div>if&nbsp;(successCallback)&nbsp;{
<a name="line2181"></a><div class="linenumber">2181</div><div style="width:14em;display:inline-block"></div>successCallback(stream);
<a name="line2182"></a><div class="linenumber">2182</div><div style="width:12em;display:inline-block"></div>}
<a name="line2183"></a><div class="linenumber">2183</div><div style="width:10em;display:inline-block"></div>}
<a name="line2184"></a><div class="linenumber">2184</div><div style="width:10em;display:inline-block"></div>else&nbsp;{
<a name="line2185"></a><div class="linenumber">2185</div><div style="width:12em;display:inline-block"></div>triesLeft&nbsp;-=&nbsp;1;
<a name="line2186"></a><div class="linenumber">2186</div><div style="width:12em;display:inline-block"></div>setTimeout(tryToGetSize,&nbsp;300);
<a name="line2187"></a><div class="linenumber">2187</div><div style="width:10em;display:inline-block"></div>}
<a name="line2188"></a><div class="linenumber">2188</div><div style="width:8em;display:inline-block"></div>};
<a name="line2189"></a><div class="linenumber">2189</div><div style="width:8em;display:inline-block"></div>self.setVideoObjectSrc(videoObj,&nbsp;stream);
<a name="line2190"></a><div class="linenumber">2190</div><div style="width:8em;display:inline-block"></div>tryToGetSize();
<a name="line2191"></a><div class="linenumber">2191</div><div style="width:6em;display:inline-block"></div>}
<a name="line2192"></a><div class="linenumber">2192</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line2193"></a><div class="linenumber">2193</div><div style="width:8em;display:inline-block"></div>updateConfigurationInfo();
<a name="line2194"></a><div class="linenumber">2194</div><div style="width:8em;display:inline-block"></div>if&nbsp;(successCallback)&nbsp;{
<a name="line2195"></a><div class="linenumber">2195</div><div style="width:10em;display:inline-block"></div>successCallback(stream);
<a name="line2196"></a><div class="linenumber">2196</div><div style="width:8em;display:inline-block"></div>}
<a name="line2197"></a><div class="linenumber">2197</div><div style="width:6em;display:inline-block"></div>}
<a name="line2198"></a><div class="linenumber">2198</div><div style="width:4em;display:inline-block"></div>};
<a name="line2199"></a><div class="linenumber">2199</div>
<a name="line2200"></a><div class="linenumber">2200</div><div style="width:4em;display:inline-block"></div>/**
<a name="line2201"></a><div class="linenumber">2201</div><div style="width:4em;display:inline-block"></div>*&nbsp;@private
<a name="line2202"></a><div class="linenumber">2202</div><div style="width:4em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;error
<a name="line2203"></a><div class="linenumber">2203</div><div style="width:4em;display:inline-block"></div>*/
<a name="line2204"></a><div class="linenumber">2204</div><div style="width:4em;display:inline-block"></div>var&nbsp;onUserMediaError&nbsp;=&nbsp;function(error)&nbsp;{
<a name="line2205"></a><div class="linenumber">2205</div><div style="width:6em;display:inline-block"></div>logDebug("getusermedia&nbsp;failed");
<a name="line2206"></a><div class="linenumber">2206</div><div style="width:6em;display:inline-block"></div>logDebug("failed&nbsp;to&nbsp;get&nbsp;local&nbsp;media");
<a name="line2207"></a><div class="linenumber">2207</div><div style="width:6em;display:inline-block"></div>var&nbsp;errText;
<a name="line2208"></a><div class="linenumber">2208</div><div style="width:6em;display:inline-block"></div>if&nbsp;(typeof&nbsp;error&nbsp;===&nbsp;'string')&nbsp;{
<a name="line2209"></a><div class="linenumber">2209</div><div style="width:8em;display:inline-block"></div>errText&nbsp;=&nbsp;error;
<a name="line2210"></a><div class="linenumber">2210</div><div style="width:6em;display:inline-block"></div>}
<a name="line2211"></a><div class="linenumber">2211</div><div style="width:6em;display:inline-block"></div>else&nbsp;if&nbsp;(error.name)&nbsp;{
<a name="line2212"></a><div class="linenumber">2212</div><div style="width:8em;display:inline-block"></div>errText&nbsp;=&nbsp;error.name;
<a name="line2213"></a><div class="linenumber">2213</div><div style="width:6em;display:inline-block"></div>}
<a name="line2214"></a><div class="linenumber">2214</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line2215"></a><div class="linenumber">2215</div><div style="width:8em;display:inline-block"></div>errText&nbsp;=&nbsp;"Unknown";
<a name="line2216"></a><div class="linenumber">2216</div><div style="width:6em;display:inline-block"></div>}
<a name="line2217"></a><div class="linenumber">2217</div><div style="width:6em;display:inline-block"></div>if&nbsp;(errorCallback)&nbsp;{
<a name="line2218"></a><div class="linenumber">2218</div><div style="width:8em;display:inline-block"></div>logDebug("invoking&nbsp;error&nbsp;callback",&nbsp;errText);
<a name="line2219"></a><div class="linenumber">2219</div><div style="width:8em;display:inline-block"></div>errorCallback(self.errCodes.MEDIA_ERR,&nbsp;self.format(self.getConstantString("gumFailed"),&nbsp;errText));
<a name="line2220"></a><div class="linenumber">2220</div><div style="width:6em;display:inline-block"></div>}
<a name="line2221"></a><div class="linenumber">2221</div><div style="width:6em;display:inline-block"></div>closeLocalMediaStreamByName(streamName);
<a name="line2222"></a><div class="linenumber">2222</div><div style="width:6em;display:inline-block"></div>haveAudioVideo&nbsp;=&nbsp;{
<a name="line2223"></a><div class="linenumber">2223</div><div style="width:8em;display:inline-block"></div>audio:&nbsp;false,
<a name="line2224"></a><div class="linenumber">2224</div><div style="width:8em;display:inline-block"></div>video:&nbsp;false
<a name="line2225"></a><div class="linenumber">2225</div><div style="width:6em;display:inline-block"></div>};
<a name="line2226"></a><div class="linenumber">2226</div><div style="width:6em;display:inline-block"></div>updateConfigurationInfo();
<a name="line2227"></a><div class="linenumber">2227</div><div style="width:4em;display:inline-block"></div>};
<a name="line2228"></a><div class="linenumber">2228</div>
<a name="line2229"></a><div class="linenumber">2229</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.audioEnabled&nbsp;&amp;&amp;&nbsp;!self.videoEnabled)&nbsp;{
<a name="line2230"></a><div class="linenumber">2230</div><div style="width:6em;display:inline-block"></div>onUserMediaError(self.getConstantString("requireAudioOrVideo"));
<a name="line2231"></a><div class="linenumber">2231</div><div style="width:6em;display:inline-block"></div>return;
<a name="line2232"></a><div class="linenumber">2232</div><div style="width:4em;display:inline-block"></div>}
<a name="line2233"></a><div class="linenumber">2233</div>
<a name="line2234"></a><div class="linenumber">2234</div><div style="width:4em;display:inline-block"></div>function&nbsp;getCurrentTime()&nbsp;{
<a name="line2235"></a><div class="linenumber">2235</div><div style="width:6em;display:inline-block"></div>return&nbsp;(new&nbsp;Date()).getTime();
<a name="line2236"></a><div class="linenumber">2236</div><div style="width:4em;display:inline-block"></div>}
<a name="line2237"></a><div class="linenumber">2237</div>
<a name="line2238"></a><div class="linenumber">2238</div><div style="width:4em;display:inline-block"></div>var&nbsp;firstCallTime;
<a name="line2239"></a><div class="linenumber">2239</div><div style="width:4em;display:inline-block"></div>function&nbsp;tryAgain(err)&nbsp;{
<a name="line2240"></a><div class="linenumber">2240</div><div style="width:6em;display:inline-block"></div>var&nbsp;currentTime&nbsp;=&nbsp;getCurrentTime();
<a name="line2241"></a><div class="linenumber">2241</div><div style="width:6em;display:inline-block"></div>if&nbsp;(currentTime&nbsp;&lt;&nbsp;firstCallTime&nbsp;+&nbsp;1000)&nbsp;{
<a name="line2242"></a><div class="linenumber">2242</div><div style="width:8em;display:inline-block"></div>logDebug("Trying&nbsp;getUserMedia&nbsp;a&nbsp;second&nbsp;time");
<a name="line2243"></a><div class="linenumber">2243</div><div style="width:8em;display:inline-block"></div>try&nbsp;{
<a name="line2244"></a><div class="linenumber">2244</div><div style="width:10em;display:inline-block"></div>navigator.getUserMedia(mode,&nbsp;onUserMediaSuccess,&nbsp;onUserMediaError);
<a name="line2245"></a><div class="linenumber">2245</div><div style="width:8em;display:inline-block"></div>}&nbsp;catch&nbsp;(e)&nbsp;{
<a name="line2246"></a><div class="linenumber">2246</div><div style="width:10em;display:inline-block"></div>onUserMediaError(err);
<a name="line2247"></a><div class="linenumber">2247</div><div style="width:8em;display:inline-block"></div>}
<a name="line2248"></a><div class="linenumber">2248</div><div style="width:6em;display:inline-block"></div>}
<a name="line2249"></a><div class="linenumber">2249</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line2250"></a><div class="linenumber">2250</div><div style="width:8em;display:inline-block"></div>onUserMediaError(err);
<a name="line2251"></a><div class="linenumber">2251</div><div style="width:6em;display:inline-block"></div>}
<a name="line2252"></a><div class="linenumber">2252</div><div style="width:4em;display:inline-block"></div>}
<a name="line2253"></a><div class="linenumber">2253</div>
<a name="line2254"></a><div class="linenumber">2254</div><div style="width:4em;display:inline-block"></div>//
<a name="line2255"></a><div class="linenumber">2255</div><div style="width:4em;display:inline-block"></div>//&nbsp;getUserMedia&nbsp;sometimes&nbsp;fails&nbsp;the&nbsp;first&nbsp;time&nbsp;I&nbsp;call&nbsp;it.&nbsp;I&nbsp;suspect&nbsp;it's&nbsp;a&nbsp;page&nbsp;loading
<a name="line2256"></a><div class="linenumber">2256</div><div style="width:4em;display:inline-block"></div>//&nbsp;issue.&nbsp;So&nbsp;I'm&nbsp;going&nbsp;to&nbsp;try&nbsp;adding&nbsp;a&nbsp;1&nbsp;second&nbsp;delay&nbsp;to&nbsp;allow&nbsp;things&nbsp;to&nbsp;settle&nbsp;down&nbsp;first.
<a name="line2257"></a><div class="linenumber">2257</div><div style="width:4em;display:inline-block"></div>//&nbsp;In&nbsp;addition,&nbsp;I'm&nbsp;going&nbsp;to&nbsp;try&nbsp;again&nbsp;after&nbsp;3&nbsp;seconds.
<a name="line2258"></a><div class="linenumber">2258</div><div style="width:4em;display:inline-block"></div>//
<a name="line2259"></a><div class="linenumber">2259</div><div style="width:4em;display:inline-block"></div>try&nbsp;{
<a name="line2260"></a><div class="linenumber">2260</div><div style="width:6em;display:inline-block"></div>firstCallTime&nbsp;=&nbsp;getCurrentTime();
<a name="line2261"></a><div class="linenumber">2261</div><div style="width:6em;display:inline-block"></div>navigator.getUserMedia(mode,&nbsp;onUserMediaSuccess,&nbsp;tryAgain);
<a name="line2262"></a><div class="linenumber">2262</div><div style="width:4em;display:inline-block"></div>}&nbsp;catch&nbsp;(err)&nbsp;{
<a name="line2263"></a><div class="linenumber">2263</div><div style="width:6em;display:inline-block"></div>tryAgain(err);
<a name="line2264"></a><div class="linenumber">2264</div><div style="width:4em;display:inline-block"></div>}
<a name="line2265"></a><div class="linenumber">2265</div><div style="width:2em;display:inline-block"></div>};
<a name="line2266"></a><div class="linenumber">2266</div>
<a name="line2267"></a><div class="linenumber">2267</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2268"></a><div class="linenumber">2268</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;callback&nbsp;used&nbsp;to&nbsp;decide&nbsp;whether&nbsp;to&nbsp;accept&nbsp;or&nbsp;reject&nbsp;an&nbsp;incoming&nbsp;call.
<a name="line2269"></a><div class="linenumber">2269</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;acceptCheck&nbsp;takes&nbsp;the&nbsp;arguments&nbsp;(callerEasyrtcid,&nbsp;acceptor).
<a name="line2270"></a><div class="linenumber">2270</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;acceptCheck&nbsp;callback&nbsp;is&nbsp;passed&nbsp;an&nbsp;easyrtcid&nbsp;and&nbsp;an&nbsp;acceptor&nbsp;function.&nbsp;The&nbsp;acceptor&nbsp;function&nbsp;should&nbsp;be&nbsp;called&nbsp;with&nbsp;either
<a name="line2271"></a><div class="linenumber">2271</div><div style="width:2em;display:inline-block"></div>*&nbsp;a&nbsp;true&nbsp;value&nbsp;(accept&nbsp;the&nbsp;call)&nbsp;or&nbsp;false&nbsp;value(&nbsp;reject&nbsp;the&nbsp;call)&nbsp;as&nbsp;it's&nbsp;first&nbsp;argument,&nbsp;and&nbsp;optionally,
<a name="line2272"></a><div class="linenumber">2272</div><div style="width:2em;display:inline-block"></div>*&nbsp;an&nbsp;array&nbsp;of&nbsp;local&nbsp;media&nbsp;streamNames&nbsp;as&nbsp;a&nbsp;second&nbsp;argument.
<a name="line2273"></a><div class="linenumber">2273</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2274"></a><div class="linenumber">2274</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setAcceptChecker(&nbsp;function(easyrtcid,&nbsp;acceptor){
<a name="line2275"></a><div class="linenumber">2275</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;easyrtc.idToName(easyrtcid)&nbsp;===&nbsp;'Fred'&nbsp;){
<a name="line2276"></a><div class="linenumber">2276</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acceptor(true);
<a name="line2277"></a><div class="linenumber">2277</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2278"></a><div class="linenumber">2278</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if(&nbsp;easyrtc.idToName(easyrtcid)&nbsp;===&nbsp;'Barney'&nbsp;){
<a name="line2279"></a><div class="linenumber">2279</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setTimeout(&nbsp;function(){
<a name="line2280"></a><div class="linenumber">2280</div><div style="width:2em;display:inline-block"></div>acceptor(true,&nbsp;['myOtherCam']);&nbsp;//&nbsp;myOtherCam&nbsp;presumed&nbsp;to&nbsp;a&nbsp;streamName
<a name="line2281"></a><div class="linenumber">2281</div><div style="width:2em;display:inline-block"></div>},&nbsp;10000);
<a name="line2282"></a><div class="linenumber">2282</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2283"></a><div class="linenumber">2283</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else{
<a name="line2284"></a><div class="linenumber">2284</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;acceptor(false);
<a name="line2285"></a><div class="linenumber">2285</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2286"></a><div class="linenumber">2286</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2287"></a><div class="linenumber">2287</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2288"></a><div class="linenumber">2288</div><div style="width:2em;display:inline-block"></div>this.setAcceptChecker&nbsp;=&nbsp;function(acceptCheck)&nbsp;{
<a name="line2289"></a><div class="linenumber">2289</div><div style="width:4em;display:inline-block"></div>self.acceptCheck&nbsp;=&nbsp;acceptCheck;
<a name="line2290"></a><div class="linenumber">2290</div><div style="width:2em;display:inline-block"></div>};
<a name="line2291"></a><div class="linenumber">2291</div>
<a name="line2292"></a><div class="linenumber">2292</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2293"></a><div class="linenumber">2293</div><div style="width:2em;display:inline-block"></div>*&nbsp;easyrtc.setStreamAcceptor&nbsp;sets&nbsp;a&nbsp;callback&nbsp;to&nbsp;receive&nbsp;media&nbsp;streams&nbsp;from&nbsp;other&nbsp;peers,&nbsp;independent
<a name="line2294"></a><div class="linenumber">2294</div><div style="width:2em;display:inline-block"></div>*&nbsp;of&nbsp;where&nbsp;the&nbsp;call&nbsp;was&nbsp;initiated&nbsp;(caller&nbsp;or&nbsp;callee).
<a name="line2295"></a><div class="linenumber">2295</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;acceptor&nbsp;takes&nbsp;arguments&nbsp;(caller,&nbsp;mediaStream,&nbsp;mediaStreamName)
<a name="line2296"></a><div class="linenumber">2296</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2297"></a><div class="linenumber">2297</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;easyrtc.setStreamAcceptor(function(easyrtcid,&nbsp;stream,&nbsp;streamName){
<a name="line2298"></a><div class="linenumber">2298</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById('callerName').innerHTML&nbsp;=&nbsp;easyrtc.idToName(easyrtcid);
<a name="line2299"></a><div class="linenumber">2299</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoObjectSrc(&nbsp;document.getElementById("callerVideo"),&nbsp;stream);
<a name="line2300"></a><div class="linenumber">2300</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;});
<a name="line2301"></a><div class="linenumber">2301</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2302"></a><div class="linenumber">2302</div><div style="width:2em;display:inline-block"></div>this.setStreamAcceptor&nbsp;=&nbsp;function(acceptor)&nbsp;{
<a name="line2303"></a><div class="linenumber">2303</div><div style="width:4em;display:inline-block"></div>self.streamAcceptor&nbsp;=&nbsp;acceptor;
<a name="line2304"></a><div class="linenumber">2304</div><div style="width:2em;display:inline-block"></div>};
<a name="line2305"></a><div class="linenumber">2305</div>
<a name="line2306"></a><div class="linenumber">2306</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sets&nbsp;the&nbsp;easyrtc.onError&nbsp;field&nbsp;to&nbsp;a&nbsp;user&nbsp;specified&nbsp;function.
<a name="line2307"></a><div class="linenumber">2307</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;errListener&nbsp;takes&nbsp;an&nbsp;object&nbsp;of&nbsp;the&nbsp;form&nbsp;{errorCode:&nbsp;String,&nbsp;errorText:&nbsp;String}
<a name="line2308"></a><div class="linenumber">2308</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2309"></a><div class="linenumber">2309</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setOnError(&nbsp;function(errorObject){
<a name="line2310"></a><div class="linenumber">2310</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById("errMessageDiv").innerHTML&nbsp;+=&nbsp;errorObject.errorText;
<a name="line2311"></a><div class="linenumber">2311</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2312"></a><div class="linenumber">2312</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2313"></a><div class="linenumber">2313</div><div style="width:2em;display:inline-block"></div>self.setOnError&nbsp;=&nbsp;function(errListener)&nbsp;{
<a name="line2314"></a><div class="linenumber">2314</div><div style="width:4em;display:inline-block"></div>self.onError&nbsp;=&nbsp;errListener;
<a name="line2315"></a><div class="linenumber">2315</div><div style="width:2em;display:inline-block"></div>};
<a name="line2316"></a><div class="linenumber">2316</div>
<a name="line2317"></a><div class="linenumber">2317</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2318"></a><div class="linenumber">2318</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;callCancelled&nbsp;callback.&nbsp;This&nbsp;will&nbsp;be&nbsp;called&nbsp;when&nbsp;a&nbsp;remote&nbsp;user
<a name="line2319"></a><div class="linenumber">2319</div><div style="width:2em;display:inline-block"></div>*&nbsp;initiates&nbsp;a&nbsp;call&nbsp;to&nbsp;you,&nbsp;but&nbsp;does&nbsp;a&nbsp;"hangup"&nbsp;before&nbsp;you&nbsp;have&nbsp;a&nbsp;chance&nbsp;to&nbsp;get&nbsp;his&nbsp;video&nbsp;stream.
<a name="line2320"></a><div class="linenumber">2320</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callCancelled&nbsp;takes&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;an&nbsp;argument&nbsp;and&nbsp;a&nbsp;boolean&nbsp;that&nbsp;indicates&nbsp;whether
<a name="line2321"></a><div class="linenumber">2321</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;the&nbsp;call&nbsp;was&nbsp;explicitly&nbsp;cancelled&nbsp;remotely&nbsp;(true),&nbsp;or&nbsp;actually&nbsp;accepted&nbsp;by&nbsp;the&nbsp;user&nbsp;attempting&nbsp;a&nbsp;call&nbsp;to
<a name="line2322"></a><div class="linenumber">2322</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;the&nbsp;same&nbsp;party.
<a name="line2323"></a><div class="linenumber">2323</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2324"></a><div class="linenumber">2324</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setCallCancelled(&nbsp;function(easyrtcid,&nbsp;explicitlyCancelled){
<a name="line2325"></a><div class="linenumber">2325</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;explicitlyCancelled&nbsp;){
<a name="line2326"></a><div class="linenumber">2326</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(easyrtc.idToName(easyrtcid)&nbsp;+&nbsp;"&nbsp;stopped&nbsp;trying&nbsp;to&nbsp;reach&nbsp;you");
<a name="line2327"></a><div class="linenumber">2327</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2328"></a><div class="linenumber">2328</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else{
<a name="line2329"></a><div class="linenumber">2329</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("Implicitly&nbsp;called&nbsp;"&nbsp;&nbsp;+&nbsp;easyrtc.idToName(easyrtcid));
<a name="line2330"></a><div class="linenumber">2330</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2331"></a><div class="linenumber">2331</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2332"></a><div class="linenumber">2332</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2333"></a><div class="linenumber">2333</div><div style="width:2em;display:inline-block"></div>this.setCallCancelled&nbsp;=&nbsp;function(callCancelled)&nbsp;{
<a name="line2334"></a><div class="linenumber">2334</div><div style="width:4em;display:inline-block"></div>self.callCancelled&nbsp;=&nbsp;callCancelled;
<a name="line2335"></a><div class="linenumber">2335</div><div style="width:2em;display:inline-block"></div>};
<a name="line2336"></a><div class="linenumber">2336</div>
<a name="line2337"></a><div class="linenumber">2337</div><div style="width:2em;display:inline-block"></div>/**&nbsp;&nbsp;Sets&nbsp;a&nbsp;callback&nbsp;to&nbsp;receive&nbsp;notification&nbsp;of&nbsp;a&nbsp;media&nbsp;stream&nbsp;closing.&nbsp;The&nbsp;usual
<a name="line2338"></a><div class="linenumber">2338</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;use&nbsp;of&nbsp;this&nbsp;is&nbsp;to&nbsp;clear&nbsp;the&nbsp;source&nbsp;of&nbsp;your&nbsp;video&nbsp;object&nbsp;so&nbsp;you&nbsp;aren't&nbsp;left&nbsp;with
<a name="line2339"></a><div class="linenumber">2339</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;the&nbsp;last&nbsp;frame&nbsp;of&nbsp;the&nbsp;video&nbsp;displayed&nbsp;on&nbsp;it.
<a name="line2340"></a><div class="linenumber">2340</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{Function}&nbsp;onStreamClosed&nbsp;takes&nbsp;an&nbsp;easyrtcid&nbsp;as&nbsp;it's&nbsp;first&nbsp;parameter,&nbsp;the&nbsp;stream&nbsp;as&nbsp;it's&nbsp;second&nbsp;argument,&nbsp;and&nbsp;name&nbsp;of&nbsp;the&nbsp;video&nbsp;stream&nbsp;as&nbsp;it's&nbsp;third.
<a name="line2341"></a><div class="linenumber">2341</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@example
<a name="line2342"></a><div class="linenumber">2342</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setOnStreamClosed(&nbsp;function(easyrtcid,&nbsp;stream,&nbsp;streamName){
<a name="line2343"></a><div class="linenumber">2343</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setVideoObjectSrc(&nbsp;document.getElementById("callerVideo"),&nbsp;"");
<a name="line2344"></a><div class="linenumber">2344</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;easyrtc.idToName(easyrtcid)&nbsp;+&nbsp;"&nbsp;closed&nbsp;stream&nbsp;"&nbsp;+&nbsp;stream.id&nbsp;+&nbsp;"&nbsp;"&nbsp;+&nbsp;streamName);
<a name="line2345"></a><div class="linenumber">2345</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2346"></a><div class="linenumber">2346</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2347"></a><div class="linenumber">2347</div><div style="width:2em;display:inline-block"></div>this.setOnStreamClosed&nbsp;=&nbsp;function(onStreamClosed)&nbsp;{
<a name="line2348"></a><div class="linenumber">2348</div><div style="width:4em;display:inline-block"></div>self.onStreamClosed&nbsp;=&nbsp;onStreamClosed;
<a name="line2349"></a><div class="linenumber">2349</div><div style="width:2em;display:inline-block"></div>};
<a name="line2350"></a><div class="linenumber">2350</div>
<a name="line2351"></a><div class="linenumber">2351</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2352"></a><div class="linenumber">2352</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;listener&nbsp;for&nbsp;data&nbsp;sent&nbsp;from&nbsp;another&nbsp;client&nbsp;(either&nbsp;peer&nbsp;to&nbsp;peer&nbsp;or&nbsp;via&nbsp;websockets).
<a name="line2353"></a><div class="linenumber">2353</div><div style="width:2em;display:inline-block"></div>*&nbsp;If&nbsp;no&nbsp;msgType&nbsp;or&nbsp;source&nbsp;is&nbsp;provided,&nbsp;the&nbsp;listener&nbsp;applies&nbsp;to&nbsp;all&nbsp;events&nbsp;that&nbsp;aren't&nbsp;otherwise&nbsp;handled.
<a name="line2354"></a><div class="linenumber">2354</div><div style="width:2em;display:inline-block"></div>*&nbsp;If&nbsp;a&nbsp;msgType&nbsp;but&nbsp;no&nbsp;source&nbsp;is&nbsp;provided,&nbsp;the&nbsp;listener&nbsp;applies&nbsp;to&nbsp;all&nbsp;messages&nbsp;of&nbsp;that&nbsp;msgType&nbsp;that&nbsp;aren't&nbsp;otherwise&nbsp;handled.
<a name="line2355"></a><div class="linenumber">2355</div><div style="width:2em;display:inline-block"></div>*&nbsp;If&nbsp;a&nbsp;msgType&nbsp;and&nbsp;a&nbsp;source&nbsp;is&nbsp;provided,&nbsp;the&nbsp;listener&nbsp;applies&nbsp;to&nbsp;only&nbsp;message&nbsp;of&nbsp;the&nbsp;specified&nbsp;type&nbsp;coming&nbsp;from&nbsp;the&nbsp;specified&nbsp;peer.
<a name="line2356"></a><div class="linenumber">2356</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;most&nbsp;specific&nbsp;case&nbsp;takes&nbsp;priority&nbsp;over&nbsp;the&nbsp;more&nbsp;general.
<a name="line2357"></a><div class="linenumber">2357</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener&nbsp;has&nbsp;the&nbsp;signature&nbsp;(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting).
<a name="line2358"></a><div class="linenumber">2358</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;msgType&nbsp;is&nbsp;a&nbsp;string.&nbsp;targeting&nbsp;is&nbsp;null&nbsp;if&nbsp;the&nbsp;message&nbsp;was&nbsp;received&nbsp;using&nbsp;WebRTC&nbsp;data&nbsp;channels,&nbsp;otherwise&nbsp;it
<a name="line2359"></a><div class="linenumber">2359</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;is&nbsp;an&nbsp;object&nbsp;that&nbsp;contains&nbsp;one&nbsp;or&nbsp;more&nbsp;of&nbsp;the&nbsp;following&nbsp;string&nbsp;valued&nbsp;elements&nbsp;{targetEasyrtcid,&nbsp;targetGroup,&nbsp;targetRoom}.
<a name="line2360"></a><div class="linenumber">2360</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;msgType&nbsp;-&nbsp;a&nbsp;string,&nbsp;optional.
<a name="line2361"></a><div class="linenumber">2361</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;source&nbsp;-&nbsp;the&nbsp;sender's&nbsp;easyrtcid,&nbsp;optional.
<a name="line2362"></a><div class="linenumber">2362</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2363"></a><div class="linenumber">2363</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setPeerListener(&nbsp;function(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting){
<a name="line2364"></a><div class="linenumber">2364</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("From&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid)&nbsp;+
<a name="line2365"></a><div class="linenumber">2365</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;sent&nbsp;the&nbsp;following&nbsp;data&nbsp;"&nbsp;+&nbsp;JSON.stringify(msgData));
<a name="line2366"></a><div class="linenumber">2366</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2367"></a><div class="linenumber">2367</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setPeerListener(&nbsp;function(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting){
<a name="line2368"></a><div class="linenumber">2368</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("From&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid)&nbsp;+
<a name="line2369"></a><div class="linenumber">2369</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;sent&nbsp;the&nbsp;following&nbsp;data&nbsp;"&nbsp;+&nbsp;JSON.stringify(msgData));
<a name="line2370"></a><div class="linenumber">2370</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;'food',&nbsp;'dkdjdekj44--');
<a name="line2371"></a><div class="linenumber">2371</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setPeerListener(&nbsp;function(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting){
<a name="line2372"></a><div class="linenumber">2372</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("From&nbsp;"&nbsp;+&nbsp;easyrtcid&nbsp;+
<a name="line2373"></a><div class="linenumber">2373</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;sent&nbsp;the&nbsp;following&nbsp;data&nbsp;"&nbsp;+&nbsp;JSON.stringify(msgData));
<a name="line2374"></a><div class="linenumber">2374</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;'drink');
<a name="line2375"></a><div class="linenumber">2375</div><div style="width:2em;display:inline-block"></div>*
<a name="line2376"></a><div class="linenumber">2376</div><div style="width:2em;display:inline-block"></div>*
<a name="line2377"></a><div class="linenumber">2377</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2378"></a><div class="linenumber">2378</div><div style="width:2em;display:inline-block"></div>this.setPeerListener&nbsp;=&nbsp;function(listener,&nbsp;msgType,&nbsp;source)&nbsp;{
<a name="line2379"></a><div class="linenumber">2379</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!msgType)&nbsp;{
<a name="line2380"></a><div class="linenumber">2380</div><div style="width:6em;display:inline-block"></div>receivePeer.cb&nbsp;=&nbsp;listener;
<a name="line2381"></a><div class="linenumber">2381</div><div style="width:4em;display:inline-block"></div>}
<a name="line2382"></a><div class="linenumber">2382</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2383"></a><div class="linenumber">2383</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!receivePeer.msgTypes[msgType])&nbsp;{
<a name="line2384"></a><div class="linenumber">2384</div><div style="width:8em;display:inline-block"></div>receivePeer.msgTypes[msgType]&nbsp;=&nbsp;{sources:&nbsp;{}};
<a name="line2385"></a><div class="linenumber">2385</div><div style="width:6em;display:inline-block"></div>}
<a name="line2386"></a><div class="linenumber">2386</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!source)&nbsp;{
<a name="line2387"></a><div class="linenumber">2387</div><div style="width:8em;display:inline-block"></div>receivePeer.msgTypes[msgType].cb&nbsp;=&nbsp;listener;
<a name="line2388"></a><div class="linenumber">2388</div><div style="width:6em;display:inline-block"></div>}
<a name="line2389"></a><div class="linenumber">2389</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line2390"></a><div class="linenumber">2390</div><div style="width:8em;display:inline-block"></div>receivePeer.msgTypes[msgType].sources[source]&nbsp;=&nbsp;{cb:&nbsp;listener};
<a name="line2391"></a><div class="linenumber">2391</div><div style="width:6em;display:inline-block"></div>}
<a name="line2392"></a><div class="linenumber">2392</div><div style="width:4em;display:inline-block"></div>}
<a name="line2393"></a><div class="linenumber">2393</div><div style="width:2em;display:inline-block"></div>};
<a name="line2394"></a><div class="linenumber">2394</div><div style="width:2em;display:inline-block"></div>/*&nbsp;This&nbsp;function&nbsp;serves&nbsp;to&nbsp;distribute&nbsp;peer&nbsp;messages&nbsp;to&nbsp;the&nbsp;various&nbsp;peer&nbsp;listeners&nbsp;*/
<a name="line2395"></a><div class="linenumber">2395</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private
<a name="line2396"></a><div class="linenumber">2396</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid
<a name="line2397"></a><div class="linenumber">2397</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;msg&nbsp;-&nbsp;needs&nbsp;to&nbsp;contain&nbsp;a&nbsp;msgType&nbsp;and&nbsp;a&nbsp;msgData&nbsp;field.
<a name="line2398"></a><div class="linenumber">2398</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;targeting
<a name="line2399"></a><div class="linenumber">2399</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2400"></a><div class="linenumber">2400</div><div style="width:2em;display:inline-block"></div>this.receivePeerDistribute&nbsp;=&nbsp;function(easyrtcid,&nbsp;msg,&nbsp;targeting)&nbsp;{
<a name="line2401"></a><div class="linenumber">2401</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgType&nbsp;=&nbsp;msg.msgType;
<a name="line2402"></a><div class="linenumber">2402</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgData&nbsp;=&nbsp;msg.msgData;
<a name="line2403"></a><div class="linenumber">2403</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!msgType)&nbsp;{
<a name="line2404"></a><div class="linenumber">2404</div><div style="width:6em;display:inline-block"></div>logDebug("received&nbsp;peer&nbsp;message&nbsp;without&nbsp;msgType",&nbsp;msg);
<a name="line2405"></a><div class="linenumber">2405</div><div style="width:6em;display:inline-block"></div>return;
<a name="line2406"></a><div class="linenumber">2406</div><div style="width:4em;display:inline-block"></div>}
<a name="line2407"></a><div class="linenumber">2407</div>
<a name="line2408"></a><div class="linenumber">2408</div><div style="width:4em;display:inline-block"></div>if&nbsp;(receivePeer.msgTypes[msgType])&nbsp;{
<a name="line2409"></a><div class="linenumber">2409</div><div style="width:6em;display:inline-block"></div>if&nbsp;(receivePeer.msgTypes[msgType].sources[easyrtcid]&nbsp;&amp;&amp;
<a name="line2410"></a><div class="linenumber">2410</div><div style="width:10em;display:inline-block"></div>receivePeer.msgTypes[msgType].sources[easyrtcid].cb)&nbsp;{
<a name="line2411"></a><div class="linenumber">2411</div><div style="width:8em;display:inline-block"></div>receivePeer.msgTypes[msgType].sources[easyrtcid].cb(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting);
<a name="line2412"></a><div class="linenumber">2412</div><div style="width:8em;display:inline-block"></div>return;
<a name="line2413"></a><div class="linenumber">2413</div><div style="width:6em;display:inline-block"></div>}
<a name="line2414"></a><div class="linenumber">2414</div><div style="width:6em;display:inline-block"></div>if&nbsp;(receivePeer.msgTypes[msgType].cb)&nbsp;{
<a name="line2415"></a><div class="linenumber">2415</div><div style="width:8em;display:inline-block"></div>receivePeer.msgTypes[msgType].cb(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting);
<a name="line2416"></a><div class="linenumber">2416</div><div style="width:8em;display:inline-block"></div>return;
<a name="line2417"></a><div class="linenumber">2417</div><div style="width:6em;display:inline-block"></div>}
<a name="line2418"></a><div class="linenumber">2418</div><div style="width:4em;display:inline-block"></div>}
<a name="line2419"></a><div class="linenumber">2419</div><div style="width:4em;display:inline-block"></div>if&nbsp;(receivePeer.cb)&nbsp;{
<a name="line2420"></a><div class="linenumber">2420</div><div style="width:6em;display:inline-block"></div>receivePeer.cb(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting);
<a name="line2421"></a><div class="linenumber">2421</div><div style="width:4em;display:inline-block"></div>}
<a name="line2422"></a><div class="linenumber">2422</div><div style="width:2em;display:inline-block"></div>};
<a name="line2423"></a><div class="linenumber">2423</div>
<a name="line2424"></a><div class="linenumber">2424</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2425"></a><div class="linenumber">2425</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;a&nbsp;listener&nbsp;for&nbsp;messages&nbsp;from&nbsp;the&nbsp;server.
<a name="line2426"></a><div class="linenumber">2426</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;listener&nbsp;has&nbsp;the&nbsp;signature&nbsp;(msgType,&nbsp;msgData,&nbsp;targeting)
<a name="line2427"></a><div class="linenumber">2427</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2428"></a><div class="linenumber">2428</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setServerListener(&nbsp;function(msgType,&nbsp;msgData,&nbsp;targeting){
<a name="line2429"></a><div class="linenumber">2429</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;("The&nbsp;Server&nbsp;sent&nbsp;the&nbsp;following&nbsp;message&nbsp;"&nbsp;+&nbsp;JSON.stringify(msgData));
<a name="line2430"></a><div class="linenumber">2430</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2431"></a><div class="linenumber">2431</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2432"></a><div class="linenumber">2432</div><div style="width:2em;display:inline-block"></div>this.setServerListener&nbsp;=&nbsp;function(listener)&nbsp;{
<a name="line2433"></a><div class="linenumber">2433</div><div style="width:4em;display:inline-block"></div>receiveServerCB&nbsp;=&nbsp;listener;
<a name="line2434"></a><div class="linenumber">2434</div><div style="width:2em;display:inline-block"></div>};
<a name="line2435"></a><div class="linenumber">2435</div>
<a name="line2436"></a><div class="linenumber">2436</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2437"></a><div class="linenumber">2437</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;url&nbsp;of&nbsp;the&nbsp;Socket&nbsp;server.
<a name="line2438"></a><div class="linenumber">2438</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;node.js&nbsp;server&nbsp;is&nbsp;great&nbsp;as&nbsp;a&nbsp;socket&nbsp;server,&nbsp;but&nbsp;it&nbsp;doesn't&nbsp;have
<a name="line2439"></a><div class="linenumber">2439</div><div style="width:2em;display:inline-block"></div>*&nbsp;all&nbsp;the&nbsp;hooks&nbsp;you'd&nbsp;like&nbsp;in&nbsp;a&nbsp;general&nbsp;web&nbsp;server,&nbsp;like&nbsp;PHP&nbsp;or&nbsp;Python
<a name="line2440"></a><div class="linenumber">2440</div><div style="width:2em;display:inline-block"></div>*&nbsp;plug-ins.&nbsp;By&nbsp;setting&nbsp;the&nbsp;serverPath&nbsp;your&nbsp;application&nbsp;can&nbsp;get&nbsp;it's&nbsp;regular
<a name="line2441"></a><div class="linenumber">2441</div><div style="width:2em;display:inline-block"></div>*&nbsp;pages&nbsp;from&nbsp;a&nbsp;regular&nbsp;web&nbsp;server,&nbsp;but&nbsp;the&nbsp;EasyRTC&nbsp;library&nbsp;can&nbsp;still&nbsp;reach&nbsp;the
<a name="line2442"></a><div class="linenumber">2442</div><div style="width:2em;display:inline-block"></div>*&nbsp;socket&nbsp;server.
<a name="line2443"></a><div class="linenumber">2443</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;socketUrl
<a name="line2444"></a><div class="linenumber">2444</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;options&nbsp;an&nbsp;optional&nbsp;dictionary&nbsp;of&nbsp;options&nbsp;for&nbsp;socket.io's&nbsp;connect&nbsp;method.
<a name="line2445"></a><div class="linenumber">2445</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;default&nbsp;is&nbsp;{'connect&nbsp;timeout':&nbsp;10000,'force&nbsp;new&nbsp;connection':&nbsp;true&nbsp;}
<a name="line2446"></a><div class="linenumber">2446</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2447"></a><div class="linenumber">2447</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setSocketUrl(":8080",&nbsp;options);
<a name="line2448"></a><div class="linenumber">2448</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2449"></a><div class="linenumber">2449</div><div style="width:2em;display:inline-block"></div>this.setSocketUrl&nbsp;=&nbsp;function(socketUrl,&nbsp;options)&nbsp;{
<a name="line2450"></a><div class="linenumber">2450</div><div style="width:4em;display:inline-block"></div>logDebug("WebRTC&nbsp;signaling&nbsp;server&nbsp;URL&nbsp;set&nbsp;to&nbsp;"&nbsp;+&nbsp;socketUrl);
<a name="line2451"></a><div class="linenumber">2451</div><div style="width:4em;display:inline-block"></div>serverPath&nbsp;=&nbsp;socketUrl;
<a name="line2452"></a><div class="linenumber">2452</div><div style="width:4em;display:inline-block"></div>if(&nbsp;options&nbsp;)&nbsp;{
<a name="line2453"></a><div class="linenumber">2453</div><div style="width:6em;display:inline-block"></div>connectionOptions&nbsp;=&nbsp;options;
<a name="line2454"></a><div class="linenumber">2454</div><div style="width:4em;display:inline-block"></div>}
<a name="line2455"></a><div class="linenumber">2455</div><div style="width:2em;display:inline-block"></div>};
<a name="line2456"></a><div class="linenumber">2456</div>
<a name="line2457"></a><div class="linenumber">2457</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2458"></a><div class="linenumber">2458</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;user&nbsp;name&nbsp;associated&nbsp;with&nbsp;the&nbsp;connection.
<a name="line2459"></a><div class="linenumber">2459</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;username&nbsp;must&nbsp;obey&nbsp;standard&nbsp;identifier&nbsp;conventions.
<a name="line2460"></a><div class="linenumber">2460</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Boolean}&nbsp;true&nbsp;if&nbsp;the&nbsp;call&nbsp;succeeded,&nbsp;false&nbsp;if&nbsp;the&nbsp;username&nbsp;was&nbsp;invalid.
<a name="line2461"></a><div class="linenumber">2461</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2462"></a><div class="linenumber">2462</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;!easyrtc.setUsername("JohnSmith")&nbsp;){
<a name="line2463"></a><div class="linenumber">2463</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.error("bad&nbsp;user&nbsp;name);
<a name="line2464"></a><div class="linenumber">2464</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2465"></a><div class="linenumber">2465</div><div style="width:2em;display:inline-block"></div>*
<a name="line2466"></a><div class="linenumber">2466</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2467"></a><div class="linenumber">2467</div><div style="width:2em;display:inline-block"></div>this.setUsername&nbsp;=&nbsp;function(username)&nbsp;{
<a name="line2468"></a><div class="linenumber">2468</div><div style="width:4em;display:inline-block"></div>if(&nbsp;self.myEasyrtcid&nbsp;)&nbsp;{
<a name="line2469"></a><div class="linenumber">2469</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"easyrtc.setUsername&nbsp;called&nbsp;after&nbsp;authentication");
<a name="line2470"></a><div class="linenumber">2470</div><div style="width:6em;display:inline-block"></div>return&nbsp;false;
<a name="line2471"></a><div class="linenumber">2471</div><div style="width:4em;display:inline-block"></div>}
<a name="line2472"></a><div class="linenumber">2472</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(self.isNameValid(username))&nbsp;{
<a name="line2473"></a><div class="linenumber">2473</div><div style="width:6em;display:inline-block"></div>self.username&nbsp;=&nbsp;username;
<a name="line2474"></a><div class="linenumber">2474</div><div style="width:6em;display:inline-block"></div>return&nbsp;true;
<a name="line2475"></a><div class="linenumber">2475</div><div style="width:4em;display:inline-block"></div>}
<a name="line2476"></a><div class="linenumber">2476</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2477"></a><div class="linenumber">2477</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.BAD_NAME,&nbsp;self.format(self.getConstantString("badUserName"),&nbsp;username));
<a name="line2478"></a><div class="linenumber">2478</div><div style="width:6em;display:inline-block"></div>return&nbsp;false;
<a name="line2479"></a><div class="linenumber">2479</div><div style="width:4em;display:inline-block"></div>}
<a name="line2480"></a><div class="linenumber">2480</div><div style="width:2em;display:inline-block"></div>};
<a name="line2481"></a><div class="linenumber">2481</div>
<a name="line2482"></a><div class="linenumber">2482</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2483"></a><div class="linenumber">2483</div><div style="width:2em;display:inline-block"></div>*&nbsp;Get&nbsp;an&nbsp;array&nbsp;of&nbsp;easyrtcids&nbsp;that&nbsp;are&nbsp;using&nbsp;a&nbsp;particular&nbsp;username
<a name="line2484"></a><div class="linenumber">2484</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;username&nbsp;-&nbsp;the&nbsp;username&nbsp;of&nbsp;interest.
<a name="line2485"></a><div class="linenumber">2485</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;room&nbsp;-&nbsp;an&nbsp;optional&nbsp;room&nbsp;name&nbsp;argument&nbsp;limiting&nbsp;results&nbsp;to&nbsp;a&nbsp;particular&nbsp;room.
<a name="line2486"></a><div class="linenumber">2486</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Array}&nbsp;an&nbsp;array&nbsp;of&nbsp;{easyrtcid:id,&nbsp;roomName:&nbsp;roomName}.
<a name="line2487"></a><div class="linenumber">2487</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2488"></a><div class="linenumber">2488</div><div style="width:2em;display:inline-block"></div>this.usernameToIds&nbsp;=&nbsp;function(username,&nbsp;room)&nbsp;{
<a name="line2489"></a><div class="linenumber">2489</div><div style="width:4em;display:inline-block"></div>var&nbsp;results&nbsp;=&nbsp;[];
<a name="line2490"></a><div class="linenumber">2490</div><div style="width:4em;display:inline-block"></div>var&nbsp;id,&nbsp;roomName;
<a name="line2491"></a><div class="linenumber">2491</div><div style="width:4em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;lastLoggedInList)&nbsp;{
<a name="line2492"></a><div class="linenumber">2492</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!lastLoggedInList.hasOwnProperty(roomName))&nbsp;{
<a name="line2493"></a><div class="linenumber">2493</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line2494"></a><div class="linenumber">2494</div><div style="width:6em;display:inline-block"></div>}
<a name="line2495"></a><div class="linenumber">2495</div><div style="width:6em;display:inline-block"></div>if&nbsp;(room&nbsp;&amp;&amp;&nbsp;roomName&nbsp;!==&nbsp;room)&nbsp;{
<a name="line2496"></a><div class="linenumber">2496</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line2497"></a><div class="linenumber">2497</div><div style="width:6em;display:inline-block"></div>}
<a name="line2498"></a><div class="linenumber">2498</div><div style="width:6em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;lastLoggedInList[roomName])&nbsp;{
<a name="line2499"></a><div class="linenumber">2499</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!lastLoggedInList[roomName].hasOwnProperty(id))&nbsp;{
<a name="line2500"></a><div class="linenumber">2500</div><div style="width:10em;display:inline-block"></div>continue;
<a name="line2501"></a><div class="linenumber">2501</div><div style="width:8em;display:inline-block"></div>}
<a name="line2502"></a><div class="linenumber">2502</div><div style="width:8em;display:inline-block"></div>if&nbsp;(lastLoggedInList[roomName][id].username&nbsp;===&nbsp;username)&nbsp;{
<a name="line2503"></a><div class="linenumber">2503</div><div style="width:10em;display:inline-block"></div>results.push({
<a name="line2504"></a><div class="linenumber">2504</div><div style="width:12em;display:inline-block"></div>easyrtcid:&nbsp;id,
<a name="line2505"></a><div class="linenumber">2505</div><div style="width:12em;display:inline-block"></div>roomName:&nbsp;roomName
<a name="line2506"></a><div class="linenumber">2506</div><div style="width:10em;display:inline-block"></div>});
<a name="line2507"></a><div class="linenumber">2507</div><div style="width:8em;display:inline-block"></div>}
<a name="line2508"></a><div class="linenumber">2508</div><div style="width:6em;display:inline-block"></div>}
<a name="line2509"></a><div class="linenumber">2509</div><div style="width:4em;display:inline-block"></div>}
<a name="line2510"></a><div class="linenumber">2510</div><div style="width:4em;display:inline-block"></div>return&nbsp;results;
<a name="line2511"></a><div class="linenumber">2511</div><div style="width:2em;display:inline-block"></div>};
<a name="line2512"></a><div class="linenumber">2512</div>
<a name="line2513"></a><div class="linenumber">2513</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2514"></a><div class="linenumber">2514</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;another&nbsp;peers&nbsp;API&nbsp;field,&nbsp;if&nbsp;it&nbsp;exists.
<a name="line2515"></a><div class="linenumber">2515</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{type}&nbsp;roomName
<a name="line2516"></a><div class="linenumber">2516</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{type}&nbsp;easyrtcid
<a name="line2517"></a><div class="linenumber">2517</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{type}&nbsp;fieldName
<a name="line2518"></a><div class="linenumber">2518</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;&nbsp;Undefined&nbsp;if&nbsp;the&nbsp;attribute&nbsp;does&nbsp;not&nbsp;exist,&nbsp;its&nbsp;value&nbsp;otherwise.
<a name="line2519"></a><div class="linenumber">2519</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2520"></a><div class="linenumber">2520</div><div style="width:2em;display:inline-block"></div>this.getRoomApiField&nbsp;=&nbsp;function(roomName,&nbsp;easyrtcid,&nbsp;fieldName)&nbsp;{
<a name="line2521"></a><div class="linenumber">2521</div><div style="width:4em;display:inline-block"></div>if&nbsp;(lastLoggedInList[roomName]&nbsp;&amp;&amp;
<a name="line2522"></a><div class="linenumber">2522</div><div style="width:8em;display:inline-block"></div>lastLoggedInList[roomName][easyrtcid]&nbsp;&amp;&amp;
<a name="line2523"></a><div class="linenumber">2523</div><div style="width:8em;display:inline-block"></div>lastLoggedInList[roomName][easyrtcid].apiField&nbsp;&amp;&amp;
<a name="line2524"></a><div class="linenumber">2524</div><div style="width:8em;display:inline-block"></div>lastLoggedInList[roomName][easyrtcid].apiField[fieldName])&nbsp;{
<a name="line2525"></a><div class="linenumber">2525</div><div style="width:6em;display:inline-block"></div>return&nbsp;lastLoggedInList[roomName][easyrtcid].apiField[fieldName].fieldValue;
<a name="line2526"></a><div class="linenumber">2526</div><div style="width:4em;display:inline-block"></div>}
<a name="line2527"></a><div class="linenumber">2527</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2528"></a><div class="linenumber">2528</div><div style="width:6em;display:inline-block"></div>return&nbsp;undefined;
<a name="line2529"></a><div class="linenumber">2529</div><div style="width:4em;display:inline-block"></div>}
<a name="line2530"></a><div class="linenumber">2530</div><div style="width:2em;display:inline-block"></div>};
<a name="line2531"></a><div class="linenumber">2531</div>
<a name="line2532"></a><div class="linenumber">2532</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2533"></a><div class="linenumber">2533</div><div style="width:2em;display:inline-block"></div>*&nbsp;Set&nbsp;the&nbsp;authentication&nbsp;credential&nbsp;if&nbsp;needed.
<a name="line2534"></a><div class="linenumber">2534</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;credentialParm&nbsp;-&nbsp;a&nbsp;JSONable&nbsp;object.
<a name="line2535"></a><div class="linenumber">2535</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2536"></a><div class="linenumber">2536</div><div style="width:2em;display:inline-block"></div>this.setCredential&nbsp;=&nbsp;function(credentialParm)&nbsp;{
<a name="line2537"></a><div class="linenumber">2537</div><div style="width:4em;display:inline-block"></div>try&nbsp;{
<a name="line2538"></a><div class="linenumber">2538</div><div style="width:6em;display:inline-block"></div>JSON.stringify(credentialParm);
<a name="line2539"></a><div class="linenumber">2539</div><div style="width:6em;display:inline-block"></div>credential&nbsp;=&nbsp;credentialParm;
<a name="line2540"></a><div class="linenumber">2540</div><div style="width:6em;display:inline-block"></div>return&nbsp;true;
<a name="line2541"></a><div class="linenumber">2541</div><div style="width:4em;display:inline-block"></div>}
<a name="line2542"></a><div class="linenumber">2542</div><div style="width:4em;display:inline-block"></div>catch&nbsp;(oops)&nbsp;{
<a name="line2543"></a><div class="linenumber">2543</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.BAD_CREDENTIAL,&nbsp;"easyrtc.setCredential&nbsp;passed&nbsp;a&nbsp;non-JSON-able&nbsp;object");
<a name="line2544"></a><div class="linenumber">2544</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"easyrtc.setCredential&nbsp;passed&nbsp;a&nbsp;non-JSON-able&nbsp;object";
<a name="line2545"></a><div class="linenumber">2545</div><div style="width:4em;display:inline-block"></div>}
<a name="line2546"></a><div class="linenumber">2546</div><div style="width:2em;display:inline-block"></div>};
<a name="line2547"></a><div class="linenumber">2547</div>
<a name="line2548"></a><div class="linenumber">2548</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2549"></a><div class="linenumber">2549</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;listener&nbsp;for&nbsp;socket&nbsp;disconnection&nbsp;by&nbsp;external&nbsp;(to&nbsp;the&nbsp;API)&nbsp;reasons.
<a name="line2550"></a><div class="linenumber">2550</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;disconnectListener&nbsp;takes&nbsp;no&nbsp;arguments&nbsp;and&nbsp;is&nbsp;not&nbsp;called&nbsp;as&nbsp;a&nbsp;result&nbsp;of&nbsp;calling&nbsp;easyrtc.disconnect.
<a name="line2551"></a><div class="linenumber">2551</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2552"></a><div class="linenumber">2552</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setDisconnectListener(function(){
<a name="line2553"></a><div class="linenumber">2553</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.showError("SYSTEM-ERROR",&nbsp;"Lost&nbsp;our&nbsp;connection&nbsp;to&nbsp;the&nbsp;socket&nbsp;server");
<a name="line2554"></a><div class="linenumber">2554</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line2555"></a><div class="linenumber">2555</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2556"></a><div class="linenumber">2556</div><div style="width:2em;display:inline-block"></div>this.setDisconnectListener&nbsp;=&nbsp;function(disconnectListener)&nbsp;{
<a name="line2557"></a><div class="linenumber">2557</div><div style="width:4em;display:inline-block"></div>self.disconnectListener&nbsp;=&nbsp;disconnectListener;
<a name="line2558"></a><div class="linenumber">2558</div><div style="width:2em;display:inline-block"></div>};
<a name="line2559"></a><div class="linenumber">2559</div>
<a name="line2560"></a><div class="linenumber">2560</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2561"></a><div class="linenumber">2561</div><div style="width:2em;display:inline-block"></div>*&nbsp;Convert&nbsp;an&nbsp;easyrtcid&nbsp;to&nbsp;a&nbsp;user&nbsp;name.&nbsp;This&nbsp;is&nbsp;useful&nbsp;for&nbsp;labeling&nbsp;buttons&nbsp;and&nbsp;messages
<a name="line2562"></a><div class="linenumber">2562</div><div style="width:2em;display:inline-block"></div>*&nbsp;regarding&nbsp;peers.
<a name="line2563"></a><div class="linenumber">2563</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid
<a name="line2564"></a><div class="linenumber">2564</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{String}&nbsp;the&nbsp;username&nbsp;associated&nbsp;with&nbsp;the&nbsp;easyrtcid,&nbsp;or&nbsp;the&nbsp;easyrtcid&nbsp;if&nbsp;there&nbsp;is
<a name="line2565"></a><div class="linenumber">2565</div><div style="width:2em;display:inline-block"></div>*&nbsp;no&nbsp;associated&nbsp;username.
<a name="line2566"></a><div class="linenumber">2566</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2567"></a><div class="linenumber">2567</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;console.log(easyrtcid&nbsp;+&nbsp;"&nbsp;is&nbsp;actually&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid));
<a name="line2568"></a><div class="linenumber">2568</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2569"></a><div class="linenumber">2569</div><div style="width:2em;display:inline-block"></div>this.idToName&nbsp;=&nbsp;function(easyrtcid)&nbsp;{
<a name="line2570"></a><div class="linenumber">2570</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomName;
<a name="line2571"></a><div class="linenumber">2571</div><div style="width:4em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;lastLoggedInList)&nbsp;{
<a name="line2572"></a><div class="linenumber">2572</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!lastLoggedInList.hasOwnProperty(roomName))&nbsp;{
<a name="line2573"></a><div class="linenumber">2573</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line2574"></a><div class="linenumber">2574</div><div style="width:6em;display:inline-block"></div>}
<a name="line2575"></a><div class="linenumber">2575</div><div style="width:6em;display:inline-block"></div>if&nbsp;(lastLoggedInList[roomName][easyrtcid])&nbsp;{
<a name="line2576"></a><div class="linenumber">2576</div><div style="width:8em;display:inline-block"></div>if&nbsp;(lastLoggedInList[roomName][easyrtcid].username)&nbsp;{
<a name="line2577"></a><div class="linenumber">2577</div><div style="width:10em;display:inline-block"></div>return&nbsp;lastLoggedInList[roomName][easyrtcid].username;
<a name="line2578"></a><div class="linenumber">2578</div><div style="width:8em;display:inline-block"></div>}
<a name="line2579"></a><div class="linenumber">2579</div><div style="width:6em;display:inline-block"></div>}
<a name="line2580"></a><div class="linenumber">2580</div><div style="width:4em;display:inline-block"></div>}
<a name="line2581"></a><div class="linenumber">2581</div><div style="width:4em;display:inline-block"></div>return&nbsp;easyrtcid;
<a name="line2582"></a><div class="linenumber">2582</div><div style="width:2em;display:inline-block"></div>};
<a name="line2583"></a><div class="linenumber">2583</div>
<a name="line2584"></a><div class="linenumber">2584</div><div style="width:2em;display:inline-block"></div>/*&nbsp;used&nbsp;in&nbsp;easyrtc.connect&nbsp;*/
<a name="line2585"></a><div class="linenumber">2585</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2586"></a><div class="linenumber">2586</div><div style="width:2em;display:inline-block"></div>this.webSocket&nbsp;=&nbsp;null;
<a name="line2587"></a><div class="linenumber">2587</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2588"></a><div class="linenumber">2588</div><div style="width:2em;display:inline-block"></div>var&nbsp;pc_config&nbsp;=&nbsp;{};
<a name="line2589"></a><div class="linenumber">2589</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2590"></a><div class="linenumber">2590</div><div style="width:2em;display:inline-block"></div>var&nbsp;pc_config_to_use&nbsp;=&nbsp;null;
<a name="line2591"></a><div class="linenumber">2591</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2592"></a><div class="linenumber">2592</div><div style="width:2em;display:inline-block"></div>var&nbsp;use_fresh_ice_each_peer&nbsp;=&nbsp;false;
<a name="line2593"></a><div class="linenumber">2593</div>
<a name="line2594"></a><div class="linenumber">2594</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2595"></a><div class="linenumber">2595</div><div style="width:2em;display:inline-block"></div>*&nbsp;Determines&nbsp;whether&nbsp;fresh&nbsp;ice&nbsp;server&nbsp;configuration&nbsp;should&nbsp;be&nbsp;requested&nbsp;from&nbsp;the&nbsp;server&nbsp;for&nbsp;each&nbsp;peer&nbsp;connection.
<a name="line2596"></a><div class="linenumber">2596</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Boolean}&nbsp;value&nbsp;the&nbsp;default&nbsp;is&nbsp;false.
<a name="line2597"></a><div class="linenumber">2597</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2598"></a><div class="linenumber">2598</div><div style="width:2em;display:inline-block"></div>this.setUseFreshIceEachPeerConnection&nbsp;=&nbsp;function(value)&nbsp;{
<a name="line2599"></a><div class="linenumber">2599</div><div style="width:4em;display:inline-block"></div>use_fresh_ice_each_peer&nbsp;=&nbsp;value;
<a name="line2600"></a><div class="linenumber">2600</div><div style="width:2em;display:inline-block"></div>};
<a name="line2601"></a><div class="linenumber">2601</div>
<a name="line2602"></a><div class="linenumber">2602</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2603"></a><div class="linenumber">2603</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;the&nbsp;last&nbsp;ice&nbsp;config&nbsp;supplied&nbsp;by&nbsp;the&nbsp;EasyRTC&nbsp;server.&nbsp;This&nbsp;function&nbsp;is&nbsp;not&nbsp;normally&nbsp;used,&nbsp;it&nbsp;is&nbsp;provided
<a name="line2604"></a><div class="linenumber">2604</div><div style="width:2em;display:inline-block"></div>*&nbsp;for&nbsp;people&nbsp;who&nbsp;want&nbsp;to&nbsp;try&nbsp;filtering&nbsp;ice&nbsp;server&nbsp;configuration&nbsp;on&nbsp;the&nbsp;client.
<a name="line2605"></a><div class="linenumber">2605</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Object}&nbsp;which&nbsp;has&nbsp;the&nbsp;form&nbsp;{iceServers:[ice_server_entry,&nbsp;ice_server_entry,&nbsp;...]}
<a name="line2606"></a><div class="linenumber">2606</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2607"></a><div class="linenumber">2607</div><div style="width:2em;display:inline-block"></div>this.getServerIce&nbsp;=&nbsp;function()&nbsp;{
<a name="line2608"></a><div class="linenumber">2608</div><div style="width:4em;display:inline-block"></div>return&nbsp;pc_config;
<a name="line2609"></a><div class="linenumber">2609</div><div style="width:2em;display:inline-block"></div>};
<a name="line2610"></a><div class="linenumber">2610</div>
<a name="line2611"></a><div class="linenumber">2611</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2612"></a><div class="linenumber">2612</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;ice&nbsp;server&nbsp;configuration&nbsp;that&nbsp;will&nbsp;be&nbsp;used&nbsp;in&nbsp;subsequent&nbsp;calls.&nbsp;You&nbsp;only&nbsp;need&nbsp;this&nbsp;function&nbsp;if&nbsp;you&nbsp;are&nbsp;filtering
<a name="line2613"></a><div class="linenumber">2613</div><div style="width:2em;display:inline-block"></div>*&nbsp;the&nbsp;ice&nbsp;server&nbsp;configuration&nbsp;on&nbsp;the&nbsp;client&nbsp;or&nbsp;if&nbsp;you&nbsp;are&nbsp;using&nbsp;TURN&nbsp;certificates&nbsp;that&nbsp;have&nbsp;a&nbsp;very&nbsp;short&nbsp;lifespan.
<a name="line2614"></a><div class="linenumber">2614</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;ice&nbsp;An&nbsp;object&nbsp;with&nbsp;iceServers&nbsp;element&nbsp;containing&nbsp;an&nbsp;array&nbsp;of&nbsp;ice&nbsp;server&nbsp;entries.
<a name="line2615"></a><div class="linenumber">2615</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2616"></a><div class="linenumber">2616</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.setIceUsedInCalls(&nbsp;{"iceServers":&nbsp;[
<a name="line2617"></a><div class="linenumber">2617</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<a name="line2618"></a><div class="linenumber">2618</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"url":&nbsp;"stun:stun.sipgate.net"
<a name="line2619"></a><div class="linenumber">2619</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line2620"></a><div class="linenumber">2620</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<a name="line2621"></a><div class="linenumber">2621</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"url":&nbsp;"stun:217.10.68.152"
<a name="line2622"></a><div class="linenumber">2622</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line2623"></a><div class="linenumber">2623</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<a name="line2624"></a><div class="linenumber">2624</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"url":&nbsp;"stun:stun.sipgate.net:10000"
<a name="line2625"></a><div class="linenumber">2625</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2626"></a><div class="linenumber">2626</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]});
<a name="line2627"></a><div class="linenumber">2627</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.call(...);
<a name="line2628"></a><div class="linenumber">2628</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2629"></a><div class="linenumber">2629</div><div style="width:2em;display:inline-block"></div>this.setIceUsedInCalls&nbsp;=&nbsp;function(ice)&nbsp;{
<a name="line2630"></a><div class="linenumber">2630</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!ice.iceServers)&nbsp;{
<a name="line2631"></a><div class="linenumber">2631</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Bad&nbsp;ice&nbsp;configuration&nbsp;passed&nbsp;to&nbsp;easyrtc.setIceUsedInCalls");
<a name="line2632"></a><div class="linenumber">2632</div><div style="width:4em;display:inline-block"></div>}
<a name="line2633"></a><div class="linenumber">2633</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2634"></a><div class="linenumber">2634</div><div style="width:6em;display:inline-block"></div>pc_config_to_use&nbsp;=&nbsp;ice;
<a name="line2635"></a><div class="linenumber">2635</div><div style="width:4em;display:inline-block"></div>}
<a name="line2636"></a><div class="linenumber">2636</div><div style="width:2em;display:inline-block"></div>};
<a name="line2637"></a><div class="linenumber">2637</div>
<a name="line2638"></a><div class="linenumber">2638</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2639"></a><div class="linenumber">2639</div><div style="width:2em;display:inline-block"></div>function&nbsp;getRemoteStreamByName(peerConn,&nbsp;otherUser,&nbsp;streamName)&nbsp;{
<a name="line2640"></a><div class="linenumber">2640</div>
<a name="line2641"></a><div class="linenumber">2641</div><div style="width:4em;display:inline-block"></div>var&nbsp;keyToMatch&nbsp;=&nbsp;null;
<a name="line2642"></a><div class="linenumber">2642</div><div style="width:4em;display:inline-block"></div>var&nbsp;remoteStreams&nbsp;=&nbsp;peerConn.pc.getRemoteStreams();
<a name="line2643"></a><div class="linenumber">2643</div>
<a name="line2644"></a><div class="linenumber">2644</div><div style="width:4em;display:inline-block"></div>//&nbsp;No&nbsp;streamName&nbsp;lead&nbsp;to&nbsp;default&nbsp;
<a name="line2645"></a><div class="linenumber">2645</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamName)&nbsp;{
<a name="line2646"></a><div class="linenumber">2646</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;"default";
<a name="line2647"></a><div class="linenumber">2647</div><div style="width:4em;display:inline-block"></div>}
<a name="line2648"></a><div class="linenumber">2648</div>
<a name="line2649"></a><div class="linenumber">2649</div><div style="width:4em;display:inline-block"></div>//&nbsp;default&nbsp;lead&nbsp;to&nbsp;first&nbsp;if&nbsp;available
<a name="line2650"></a><div class="linenumber">2650</div><div style="width:4em;display:inline-block"></div>if&nbsp;(streamName&nbsp;===&nbsp;"default")&nbsp;{
<a name="line2651"></a><div class="linenumber">2651</div><div style="width:6em;display:inline-block"></div>if&nbsp;(remoteStreams.length&nbsp;&gt;&nbsp;0)&nbsp;{
<a name="line2652"></a><div class="linenumber">2652</div><div style="width:8em;display:inline-block"></div>return&nbsp;remoteStreams[0];
<a name="line2653"></a><div class="linenumber">2653</div><div style="width:6em;display:inline-block"></div>}
<a name="line2654"></a><div class="linenumber">2654</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line2655"></a><div class="linenumber">2655</div><div style="width:8em;display:inline-block"></div>return&nbsp;null;
<a name="line2656"></a><div class="linenumber">2656</div><div style="width:6em;display:inline-block"></div>}
<a name="line2657"></a><div class="linenumber">2657</div><div style="width:4em;display:inline-block"></div>}
<a name="line2658"></a><div class="linenumber">2658</div>
<a name="line2659"></a><div class="linenumber">2659</div><div style="width:4em;display:inline-block"></div>//&nbsp;Get&nbsp;mediaIds&nbsp;from&nbsp;user&nbsp;roomData
<a name="line2660"></a><div class="linenumber">2660</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;roomName&nbsp;in&nbsp;self.roomData)&nbsp;{
<a name="line2661"></a><div class="linenumber">2661</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.roomData.hasOwnProperty(roomName))&nbsp;{
<a name="line2662"></a><div class="linenumber">2662</div><div style="width:8em;display:inline-block"></div>var&nbsp;mediaIds&nbsp;=&nbsp;self.getRoomApiField(roomName,&nbsp;otherUser,&nbsp;"mediaIds");
<a name="line2663"></a><div class="linenumber">2663</div><div style="width:8em;display:inline-block"></div>keyToMatch&nbsp;=&nbsp;mediaIds&nbsp;?&nbsp;mediaIds[streamName]&nbsp;:&nbsp;null;
<a name="line2664"></a><div class="linenumber">2664</div><div style="width:8em;display:inline-block"></div>if&nbsp;(keyToMatch)&nbsp;{
<a name="line2665"></a><div class="linenumber">2665</div><div style="width:10em;display:inline-block"></div>break;
<a name="line2666"></a><div class="linenumber">2666</div><div style="width:8em;display:inline-block"></div>}
<a name="line2667"></a><div class="linenumber">2667</div><div style="width:6em;display:inline-block"></div>}
<a name="line2668"></a><div class="linenumber">2668</div><div style="width:4em;display:inline-block"></div>}
<a name="line2669"></a><div class="linenumber">2669</div>
<a name="line2670"></a><div class="linenumber">2670</div><div style="width:4em;display:inline-block"></div>//&nbsp;
<a name="line2671"></a><div class="linenumber">2671</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!keyToMatch)&nbsp;{
<a name="line2672"></a><div class="linenumber">2672</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"remote&nbsp;peer&nbsp;does&nbsp;not&nbsp;have&nbsp;media&nbsp;stream&nbsp;called&nbsp;"&nbsp;+&nbsp;streamName);
<a name="line2673"></a><div class="linenumber">2673</div><div style="width:4em;display:inline-block"></div>}
<a name="line2674"></a><div class="linenumber">2674</div>
<a name="line2675"></a><div class="linenumber">2675</div><div style="width:4em;display:inline-block"></div>//&nbsp;
<a name="line2676"></a><div class="linenumber">2676</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;remoteStreams.length;&nbsp;i++)&nbsp;{
<a name="line2677"></a><div class="linenumber">2677</div><div style="width:6em;display:inline-block"></div>var&nbsp;remoteId;
<a name="line2678"></a><div class="linenumber">2678</div><div style="width:6em;display:inline-block"></div>if&nbsp;(remoteStreams[i].id)&nbsp;{
<a name="line2679"></a><div class="linenumber">2679</div><div style="width:8em;display:inline-block"></div>remoteId&nbsp;=&nbsp;remoteStreams[i].id;
<a name="line2680"></a><div class="linenumber">2680</div><div style="width:6em;display:inline-block"></div>}&nbsp;&nbsp;else&nbsp;{
<a name="line2681"></a><div class="linenumber">2681</div><div style="width:8em;display:inline-block"></div>remoteId&nbsp;=&nbsp;"default";
<a name="line2682"></a><div class="linenumber">2682</div><div style="width:6em;display:inline-block"></div>}
<a name="line2683"></a><div class="linenumber">2683</div>
<a name="line2684"></a><div class="linenumber">2684</div><div style="width:6em;display:inline-block"></div>if&nbsp;(
<a name="line2685"></a><div class="linenumber">2685</div><div style="width:8em;display:inline-block"></div>!keyToMatch&nbsp;||&nbsp;//&nbsp;No&nbsp;match
<a name="line2686"></a><div class="linenumber">2686</div><div style="width:10em;display:inline-block"></div>remoteId&nbsp;===&nbsp;keyToMatch&nbsp;||&nbsp;//&nbsp;Full&nbsp;match
<a name="line2687"></a><div class="linenumber">2687</div><div style="width:12em;display:inline-block"></div>remoteId.indexOf(keyToMatch)&nbsp;===&nbsp;0&nbsp;//&nbsp;Partial&nbsp;match
<a name="line2688"></a><div class="linenumber">2688</div><div style="width:6em;display:inline-block"></div>)&nbsp;{
<a name="line2689"></a><div class="linenumber">2689</div><div style="width:8em;display:inline-block"></div>return&nbsp;remoteStreams[i];
<a name="line2690"></a><div class="linenumber">2690</div><div style="width:6em;display:inline-block"></div>}
<a name="line2691"></a><div class="linenumber">2691</div>
<a name="line2692"></a><div class="linenumber">2692</div><div style="width:4em;display:inline-block"></div>}
<a name="line2693"></a><div class="linenumber">2693</div>
<a name="line2694"></a><div class="linenumber">2694</div><div style="width:4em;display:inline-block"></div>return&nbsp;null;
<a name="line2695"></a><div class="linenumber">2695</div><div style="width:2em;display:inline-block"></div>}
<a name="line2696"></a><div class="linenumber">2696</div>
<a name="line2697"></a><div class="linenumber">2697</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2698"></a><div class="linenumber">2698</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line2699"></a><div class="linenumber">2699</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;easyrtcid
<a name="line2700"></a><div class="linenumber">2700</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{boolean}&nbsp;checkAudio
<a name="line2701"></a><div class="linenumber">2701</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;streamName
<a name="line2702"></a><div class="linenumber">2702</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2703"></a><div class="linenumber">2703</div><div style="width:2em;display:inline-block"></div>function&nbsp;_haveTracks(easyrtcid,&nbsp;checkAudio,&nbsp;streamName)&nbsp;{
<a name="line2704"></a><div class="linenumber">2704</div><div style="width:4em;display:inline-block"></div>var&nbsp;stream,&nbsp;peerConnObj;
<a name="line2705"></a><div class="linenumber">2705</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!easyrtcid)&nbsp;{
<a name="line2706"></a><div class="linenumber">2706</div><div style="width:6em;display:inline-block"></div>stream&nbsp;=&nbsp;getLocalMediaStreamByName(streamName);
<a name="line2707"></a><div class="linenumber">2707</div><div style="width:4em;display:inline-block"></div>}
<a name="line2708"></a><div class="linenumber">2708</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2709"></a><div class="linenumber">2709</div><div style="width:6em;display:inline-block"></div>peerConnObj&nbsp;=&nbsp;peerConns[easyrtcid];
<a name="line2710"></a><div class="linenumber">2710</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!peerConnObj)&nbsp;{
<a name="line2711"></a><div class="linenumber">2711</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"haveTracks&nbsp;called&nbsp;about&nbsp;a&nbsp;peer&nbsp;you&nbsp;don't&nbsp;have&nbsp;a&nbsp;connection&nbsp;to");
<a name="line2712"></a><div class="linenumber">2712</div><div style="width:8em;display:inline-block"></div>return&nbsp;false;
<a name="line2713"></a><div class="linenumber">2713</div><div style="width:6em;display:inline-block"></div>}
<a name="line2714"></a><div class="linenumber">2714</div><div style="width:6em;display:inline-block"></div>stream&nbsp;=&nbsp;getRemoteStreamByName(peerConns[easyrtcid],&nbsp;easyrtcid,&nbsp;streamName);
<a name="line2715"></a><div class="linenumber">2715</div><div style="width:4em;display:inline-block"></div>}
<a name="line2716"></a><div class="linenumber">2716</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!stream)&nbsp;{
<a name="line2717"></a><div class="linenumber">2717</div><div style="width:6em;display:inline-block"></div>return&nbsp;false;
<a name="line2718"></a><div class="linenumber">2718</div><div style="width:4em;display:inline-block"></div>}
<a name="line2719"></a><div class="linenumber">2719</div>
<a name="line2720"></a><div class="linenumber">2720</div><div style="width:4em;display:inline-block"></div>var&nbsp;tracks;
<a name="line2721"></a><div class="linenumber">2721</div><div style="width:4em;display:inline-block"></div>try&nbsp;{
<a name="line2722"></a><div class="linenumber">2722</div>
<a name="line2723"></a><div class="linenumber">2723</div><div style="width:6em;display:inline-block"></div>if&nbsp;(checkAudio)&nbsp;{
<a name="line2724"></a><div class="linenumber">2724</div><div style="width:8em;display:inline-block"></div>tracks&nbsp;=&nbsp;stream.getAudioTracks();
<a name="line2725"></a><div class="linenumber">2725</div><div style="width:6em;display:inline-block"></div>}
<a name="line2726"></a><div class="linenumber">2726</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line2727"></a><div class="linenumber">2727</div><div style="width:8em;display:inline-block"></div>tracks&nbsp;=&nbsp;stream.getVideoTracks();
<a name="line2728"></a><div class="linenumber">2728</div><div style="width:6em;display:inline-block"></div>}
<a name="line2729"></a><div class="linenumber">2729</div>
<a name="line2730"></a><div class="linenumber">2730</div><div style="width:4em;display:inline-block"></div>}&nbsp;catch&nbsp;(oops)&nbsp;{
<a name="line2731"></a><div class="linenumber">2731</div><div style="width:6em;display:inline-block"></div>//&nbsp;TODO&nbsp;why&nbsp;do&nbsp;we&nbsp;return&nbsp;true&nbsp;here&nbsp;?
<a name="line2732"></a><div class="linenumber">2732</div><div style="width:6em;display:inline-block"></div>return&nbsp;true;
<a name="line2733"></a><div class="linenumber">2733</div><div style="width:4em;display:inline-block"></div>}
<a name="line2734"></a><div class="linenumber">2734</div>
<a name="line2735"></a><div class="linenumber">2735</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!tracks)&nbsp;{
<a name="line2736"></a><div class="linenumber">2736</div><div style="width:6em;display:inline-block"></div>return&nbsp;false;
<a name="line2737"></a><div class="linenumber">2737</div><div style="width:4em;display:inline-block"></div>}
<a name="line2738"></a><div class="linenumber">2738</div>
<a name="line2739"></a><div class="linenumber">2739</div><div style="width:4em;display:inline-block"></div>return&nbsp;tracks.length&nbsp;&gt;&nbsp;0;
<a name="line2740"></a><div class="linenumber">2740</div><div style="width:2em;display:inline-block"></div>}
<a name="line2741"></a><div class="linenumber">2741</div>
<a name="line2742"></a><div class="linenumber">2742</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Determines&nbsp;if&nbsp;a&nbsp;particular&nbsp;peer2peer&nbsp;connection&nbsp;has&nbsp;an&nbsp;audio&nbsp;track.
<a name="line2743"></a><div class="linenumber">2743</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid&nbsp;-&nbsp;the&nbsp;id&nbsp;of&nbsp;the&nbsp;other&nbsp;caller&nbsp;in&nbsp;the&nbsp;connection.&nbsp;If&nbsp;easyrtcid&nbsp;is&nbsp;not&nbsp;supplied,&nbsp;checks&nbsp;the&nbsp;local&nbsp;media.
<a name="line2744"></a><div class="linenumber">2744</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;an&nbsp;optional&nbsp;stream&nbsp;id.
<a name="line2745"></a><div class="linenumber">2745</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Boolean}&nbsp;true&nbsp;if&nbsp;there&nbsp;is&nbsp;an&nbsp;audio&nbsp;track&nbsp;or&nbsp;the&nbsp;browser&nbsp;can't&nbsp;tell&nbsp;us.
<a name="line2746"></a><div class="linenumber">2746</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2747"></a><div class="linenumber">2747</div><div style="width:2em;display:inline-block"></div>this.haveAudioTrack&nbsp;=&nbsp;function(easyrtcid,&nbsp;streamName)&nbsp;{
<a name="line2748"></a><div class="linenumber">2748</div><div style="width:4em;display:inline-block"></div>return&nbsp;_haveTracks(easyrtcid,&nbsp;true,&nbsp;streamName);
<a name="line2749"></a><div class="linenumber">2749</div><div style="width:2em;display:inline-block"></div>};
<a name="line2750"></a><div class="linenumber">2750</div>
<a name="line2751"></a><div class="linenumber">2751</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Determines&nbsp;if&nbsp;a&nbsp;particular&nbsp;peer2peer&nbsp;connection&nbsp;has&nbsp;a&nbsp;video&nbsp;track.
<a name="line2752"></a><div class="linenumber">2752</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid&nbsp;-&nbsp;the&nbsp;id&nbsp;of&nbsp;the&nbsp;other&nbsp;caller&nbsp;in&nbsp;the&nbsp;connection.&nbsp;If&nbsp;easyrtcid&nbsp;is&nbsp;not&nbsp;supplied,&nbsp;checks&nbsp;the&nbsp;local&nbsp;media.
<a name="line2753"></a><div class="linenumber">2753</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;-&nbsp;an&nbsp;optional&nbsp;stream&nbsp;id.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*
<a name="line2754"></a><div class="linenumber">2754</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Boolean}&nbsp;true&nbsp;if&nbsp;there&nbsp;is&nbsp;an&nbsp;video&nbsp;track&nbsp;or&nbsp;the&nbsp;browser&nbsp;can't&nbsp;tell&nbsp;us.
<a name="line2755"></a><div class="linenumber">2755</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2756"></a><div class="linenumber">2756</div><div style="width:2em;display:inline-block"></div>this.haveVideoTrack&nbsp;=&nbsp;function(easyrtcid,&nbsp;streamName)&nbsp;{
<a name="line2757"></a><div class="linenumber">2757</div><div style="width:4em;display:inline-block"></div>return&nbsp;_haveTracks(easyrtcid,&nbsp;false,&nbsp;streamName);
<a name="line2758"></a><div class="linenumber">2758</div><div style="width:2em;display:inline-block"></div>};
<a name="line2759"></a><div class="linenumber">2759</div>
<a name="line2760"></a><div class="linenumber">2760</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2761"></a><div class="linenumber">2761</div><div style="width:2em;display:inline-block"></div>*&nbsp;Gets&nbsp;a&nbsp;data&nbsp;field&nbsp;associated&nbsp;with&nbsp;a&nbsp;room.
<a name="line2762"></a><div class="linenumber">2762</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;roomName&nbsp;-&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;room.
<a name="line2763"></a><div class="linenumber">2763</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;fieldName&nbsp;-&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;field.
<a name="line2764"></a><div class="linenumber">2764</div><div style="width:2em;display:inline-block"></div>*&nbsp;@return&nbsp;{Object}&nbsp;dataValue&nbsp;-&nbsp;the&nbsp;value&nbsp;of&nbsp;the&nbsp;field&nbsp;if&nbsp;present,&nbsp;undefined&nbsp;if&nbsp;not&nbsp;present.
<a name="line2765"></a><div class="linenumber">2765</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2766"></a><div class="linenumber">2766</div><div style="width:2em;display:inline-block"></div>this.getRoomField&nbsp;=&nbsp;function(roomName,&nbsp;fieldName)&nbsp;{
<a name="line2767"></a><div class="linenumber">2767</div><div style="width:4em;display:inline-block"></div>var&nbsp;fields&nbsp;=&nbsp;self.getRoomFields(roomName);
<a name="line2768"></a><div class="linenumber">2768</div><div style="width:4em;display:inline-block"></div>return&nbsp;(!fields&nbsp;||&nbsp;!fields[fieldName])&nbsp;?&nbsp;undefined&nbsp;:&nbsp;fields[fieldName].fieldValue;
<a name="line2769"></a><div class="linenumber">2769</div><div style="width:2em;display:inline-block"></div>};
<a name="line2770"></a><div class="linenumber">2770</div>
<a name="line2771"></a><div class="linenumber">2771</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2772"></a><div class="linenumber">2772</div><div style="width:2em;display:inline-block"></div>var&nbsp;fields&nbsp;=&nbsp;null;
<a name="line2773"></a><div class="linenumber">2773</div>
<a name="line2774"></a><div class="linenumber">2774</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2775"></a><div class="linenumber">2775</div><div style="width:2em;display:inline-block"></div>var&nbsp;preallocatedSocketIo&nbsp;=&nbsp;null;
<a name="line2776"></a><div class="linenumber">2776</div>
<a name="line2777"></a><div class="linenumber">2777</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2778"></a><div class="linenumber">2778</div><div style="width:2em;display:inline-block"></div>var&nbsp;closedChannel&nbsp;=&nbsp;null;
<a name="line2779"></a><div class="linenumber">2779</div>
<a name="line2780"></a><div class="linenumber">2780</div><div style="width:2em;display:inline-block"></div>//
<a name="line2781"></a><div class="linenumber">2781</div><div style="width:2em;display:inline-block"></div>//&nbsp;easyrtc.disconnect&nbsp;performs&nbsp;a&nbsp;clean&nbsp;disconnection&nbsp;of&nbsp;the&nbsp;client&nbsp;from&nbsp;the&nbsp;server.
<a name="line2782"></a><div class="linenumber">2782</div><div style="width:2em;display:inline-block"></div>//
<a name="line2783"></a><div class="linenumber">2783</div><div style="width:2em;display:inline-block"></div>function&nbsp;disconnectBody()&nbsp;{
<a name="line2784"></a><div class="linenumber">2784</div><div style="width:4em;display:inline-block"></div>var&nbsp;key;
<a name="line2785"></a><div class="linenumber">2785</div><div style="width:4em;display:inline-block"></div>self.loggingOut&nbsp;=&nbsp;true;
<a name="line2786"></a><div class="linenumber">2786</div><div style="width:4em;display:inline-block"></div>offersPending&nbsp;=&nbsp;{};
<a name="line2787"></a><div class="linenumber">2787</div><div style="width:4em;display:inline-block"></div>acceptancePending&nbsp;=&nbsp;{};
<a name="line2788"></a><div class="linenumber">2788</div><div style="width:4em;display:inline-block"></div>self.disconnecting&nbsp;=&nbsp;true;
<a name="line2789"></a><div class="linenumber">2789</div><div style="width:4em;display:inline-block"></div>closedChannel&nbsp;=&nbsp;self.webSocket;
<a name="line2790"></a><div class="linenumber">2790</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.webSocketConnected)&nbsp;{
<a name="line2791"></a><div class="linenumber">2791</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!preallocatedSocketIo)&nbsp;{
<a name="line2792"></a><div class="linenumber">2792</div><div style="width:8em;display:inline-block"></div>self.webSocket.close();
<a name="line2793"></a><div class="linenumber">2793</div><div style="width:6em;display:inline-block"></div>}
<a name="line2794"></a><div class="linenumber">2794</div><div style="width:6em;display:inline-block"></div>self.webSocketConnected&nbsp;=&nbsp;false;
<a name="line2795"></a><div class="linenumber">2795</div><div style="width:4em;display:inline-block"></div>}
<a name="line2796"></a><div class="linenumber">2796</div><div style="width:4em;display:inline-block"></div>self.hangupAll();
<a name="line2797"></a><div class="linenumber">2797</div><div style="width:4em;display:inline-block"></div>if&nbsp;(roomOccupantListener)&nbsp;{
<a name="line2798"></a><div class="linenumber">2798</div><div style="width:6em;display:inline-block"></div>for&nbsp;(key&nbsp;in&nbsp;lastLoggedInList)&nbsp;{
<a name="line2799"></a><div class="linenumber">2799</div><div style="width:8em;display:inline-block"></div>if&nbsp;(lastLoggedInList.hasOwnProperty(key))&nbsp;{
<a name="line2800"></a><div class="linenumber">2800</div><div style="width:10em;display:inline-block"></div>roomOccupantListener(key,&nbsp;{},&nbsp;false);
<a name="line2801"></a><div class="linenumber">2801</div><div style="width:8em;display:inline-block"></div>}
<a name="line2802"></a><div class="linenumber">2802</div><div style="width:6em;display:inline-block"></div>}
<a name="line2803"></a><div class="linenumber">2803</div><div style="width:4em;display:inline-block"></div>}
<a name="line2804"></a><div class="linenumber">2804</div><div style="width:4em;display:inline-block"></div>lastLoggedInList&nbsp;=&nbsp;{};
<a name="line2805"></a><div class="linenumber">2805</div><div style="width:4em;display:inline-block"></div>self.emitEvent("roomOccupant",&nbsp;{});
<a name="line2806"></a><div class="linenumber">2806</div><div style="width:4em;display:inline-block"></div>self.roomData&nbsp;=&nbsp;{};
<a name="line2807"></a><div class="linenumber">2807</div><div style="width:4em;display:inline-block"></div>self.roomJoin&nbsp;=&nbsp;{};
<a name="line2808"></a><div class="linenumber">2808</div><div style="width:4em;display:inline-block"></div>self.loggingOut&nbsp;=&nbsp;false;
<a name="line2809"></a><div class="linenumber">2809</div><div style="width:4em;display:inline-block"></div>self.myEasyrtcid&nbsp;=&nbsp;null;
<a name="line2810"></a><div class="linenumber">2810</div><div style="width:4em;display:inline-block"></div>self.disconnecting&nbsp;=&nbsp;false;
<a name="line2811"></a><div class="linenumber">2811</div><div style="width:4em;display:inline-block"></div>oldConfig&nbsp;=&nbsp;{};
<a name="line2812"></a><div class="linenumber">2812</div><div style="width:2em;display:inline-block"></div>}
<a name="line2813"></a><div class="linenumber">2813</div>
<a name="line2814"></a><div class="linenumber">2814</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2815"></a><div class="linenumber">2815</div><div style="width:2em;display:inline-block"></div>*&nbsp;Disconnect&nbsp;from&nbsp;the&nbsp;EasyRTC&nbsp;server.
<a name="line2816"></a><div class="linenumber">2816</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2817"></a><div class="linenumber">2817</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.disconnect();
<a name="line2818"></a><div class="linenumber">2818</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2819"></a><div class="linenumber">2819</div><div style="width:2em;display:inline-block"></div>this.disconnect&nbsp;=&nbsp;function()&nbsp;{
<a name="line2820"></a><div class="linenumber">2820</div>
<a name="line2821"></a><div class="linenumber">2821</div><div style="width:4em;display:inline-block"></div>logDebug("attempt&nbsp;to&nbsp;disconnect&nbsp;from&nbsp;WebRTC&nbsp;signalling&nbsp;server");
<a name="line2822"></a><div class="linenumber">2822</div>
<a name="line2823"></a><div class="linenumber">2823</div><div style="width:4em;display:inline-block"></div>self.disconnecting&nbsp;=&nbsp;true;
<a name="line2824"></a><div class="linenumber">2824</div><div style="width:4em;display:inline-block"></div>self.hangupAll();
<a name="line2825"></a><div class="linenumber">2825</div><div style="width:4em;display:inline-block"></div>self.loggingOut&nbsp;=&nbsp;true;
<a name="line2826"></a><div class="linenumber">2826</div><div style="width:4em;display:inline-block"></div>//
<a name="line2827"></a><div class="linenumber">2827</div><div style="width:4em;display:inline-block"></div>//&nbsp;The&nbsp;hangupAll&nbsp;may&nbsp;try&nbsp;to&nbsp;send&nbsp;configuration&nbsp;information&nbsp;back&nbsp;to&nbsp;the&nbsp;server.
<a name="line2828"></a><div class="linenumber">2828</div><div style="width:4em;display:inline-block"></div>//&nbsp;Collecting&nbsp;that&nbsp;information&nbsp;is&nbsp;asynchronous,&nbsp;we&nbsp;don't&nbsp;actually&nbsp;close&nbsp;the
<a name="line2829"></a><div class="linenumber">2829</div><div style="width:4em;display:inline-block"></div>//&nbsp;connection&nbsp;until&nbsp;it's&nbsp;had&nbsp;a&nbsp;chance&nbsp;to&nbsp;be&nbsp;sent.&nbsp;We&nbsp;allocate&nbsp;100ms&nbsp;for&nbsp;collecting
<a name="line2830"></a><div class="linenumber">2830</div><div style="width:4em;display:inline-block"></div>//&nbsp;the&nbsp;info,&nbsp;so&nbsp;250ms&nbsp;should&nbsp;be&nbsp;sufficient&nbsp;for&nbsp;the&nbsp;disconnecting.
<a name="line2831"></a><div class="linenumber">2831</div><div style="width:4em;display:inline-block"></div>//
<a name="line2832"></a><div class="linenumber">2832</div><div style="width:4em;display:inline-block"></div>setTimeout(function()&nbsp;{
<a name="line2833"></a><div class="linenumber">2833</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.webSocket)&nbsp;{
<a name="line2834"></a><div class="linenumber">2834</div><div style="width:8em;display:inline-block"></div>try&nbsp;{
<a name="line2835"></a><div class="linenumber">2835</div><div style="width:10em;display:inline-block"></div>self.webSocket.disconnect();
<a name="line2836"></a><div class="linenumber">2836</div><div style="width:8em;display:inline-block"></div>}&nbsp;catch&nbsp;(e)&nbsp;{
<a name="line2837"></a><div class="linenumber">2837</div><div style="width:10em;display:inline-block"></div>//&nbsp;we&nbsp;don't&nbsp;really&nbsp;care&nbsp;if&nbsp;this&nbsp;fails.
<a name="line2838"></a><div class="linenumber">2838</div><div style="width:8em;display:inline-block"></div>}
<a name="line2839"></a><div class="linenumber">2839</div>
<a name="line2840"></a><div class="linenumber">2840</div><div style="width:8em;display:inline-block"></div>closedChannel&nbsp;=&nbsp;self.webSocket;
<a name="line2841"></a><div class="linenumber">2841</div><div style="width:8em;display:inline-block"></div>self.webSocket&nbsp;=&nbsp;0;
<a name="line2842"></a><div class="linenumber">2842</div><div style="width:6em;display:inline-block"></div>}
<a name="line2843"></a><div class="linenumber">2843</div><div style="width:6em;display:inline-block"></div>self.loggingOut&nbsp;=&nbsp;false;
<a name="line2844"></a><div class="linenumber">2844</div><div style="width:6em;display:inline-block"></div>self.disconnecting&nbsp;=&nbsp;false;
<a name="line2845"></a><div class="linenumber">2845</div><div style="width:6em;display:inline-block"></div>if&nbsp;(roomOccupantListener)&nbsp;{
<a name="line2846"></a><div class="linenumber">2846</div><div style="width:8em;display:inline-block"></div>roomOccupantListener(null,&nbsp;{},&nbsp;false);
<a name="line2847"></a><div class="linenumber">2847</div><div style="width:6em;display:inline-block"></div>}
<a name="line2848"></a><div class="linenumber">2848</div><div style="width:6em;display:inline-block"></div>self.emitEvent("roomOccupant",&nbsp;{});
<a name="line2849"></a><div class="linenumber">2849</div><div style="width:6em;display:inline-block"></div>oldConfig&nbsp;=&nbsp;{};
<a name="line2850"></a><div class="linenumber">2850</div><div style="width:4em;display:inline-block"></div>},&nbsp;250);
<a name="line2851"></a><div class="linenumber">2851</div><div style="width:2em;display:inline-block"></div>};
<a name="line2852"></a><div class="linenumber">2852</div>
<a name="line2853"></a><div class="linenumber">2853</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2854"></a><div class="linenumber">2854</div><div style="width:2em;display:inline-block"></div>//
<a name="line2855"></a><div class="linenumber">2855</div><div style="width:2em;display:inline-block"></div>//&nbsp;This&nbsp;function&nbsp;is&nbsp;used&nbsp;to&nbsp;send&nbsp;WebRTC&nbsp;signaling&nbsp;messages&nbsp;to&nbsp;another&nbsp;client.&nbsp;These&nbsp;messages&nbsp;all&nbsp;the&nbsp;form:
<a name="line2856"></a><div class="linenumber">2856</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;destUser:&nbsp;some&nbsp;id&nbsp;or&nbsp;null
<a name="line2857"></a><div class="linenumber">2857</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;msgType:&nbsp;one&nbsp;of&nbsp;["offer"/"answer"/"candidate","reject","hangup",&nbsp;"getRoomList"]
<a name="line2858"></a><div class="linenumber">2858</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;msgData:&nbsp;either&nbsp;null&nbsp;or&nbsp;an&nbsp;SDP&nbsp;record
<a name="line2859"></a><div class="linenumber">2859</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;successCallback:&nbsp;a&nbsp;function&nbsp;with&nbsp;the&nbsp;signature&nbsp;&nbsp;function(msgType,&nbsp;wholeMsg);
<a name="line2860"></a><div class="linenumber">2860</div><div style="width:2em;display:inline-block"></div>//&nbsp;&nbsp;&nbsp;errorCallback:&nbsp;a&nbsp;function&nbsp;with&nbsp;signature&nbsp;function(errorCode,&nbsp;errorText)
<a name="line2861"></a><div class="linenumber">2861</div><div style="width:2em;display:inline-block"></div>//
<a name="line2862"></a><div class="linenumber">2862</div><div style="width:2em;display:inline-block"></div>function&nbsp;sendSignalling(destUser,&nbsp;msgType,&nbsp;msgData,&nbsp;successCallback,&nbsp;errorCallback)&nbsp;{
<a name="line2863"></a><div class="linenumber">2863</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.webSocket)&nbsp;{
<a name="line2864"></a><div class="linenumber">2864</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Attempt&nbsp;to&nbsp;send&nbsp;message&nbsp;without&nbsp;a&nbsp;valid&nbsp;connection&nbsp;to&nbsp;the&nbsp;server.";
<a name="line2865"></a><div class="linenumber">2865</div><div style="width:4em;display:inline-block"></div>}
<a name="line2866"></a><div class="linenumber">2866</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2867"></a><div class="linenumber">2867</div><div style="width:6em;display:inline-block"></div>var&nbsp;dataToShip&nbsp;=&nbsp;{
<a name="line2868"></a><div class="linenumber">2868</div><div style="width:8em;display:inline-block"></div>msgType:&nbsp;msgType
<a name="line2869"></a><div class="linenumber">2869</div><div style="width:6em;display:inline-block"></div>};
<a name="line2870"></a><div class="linenumber">2870</div><div style="width:6em;display:inline-block"></div>if&nbsp;(destUser)&nbsp;{
<a name="line2871"></a><div class="linenumber">2871</div><div style="width:8em;display:inline-block"></div>dataToShip.targetEasyrtcid&nbsp;=&nbsp;destUser;
<a name="line2872"></a><div class="linenumber">2872</div><div style="width:6em;display:inline-block"></div>}
<a name="line2873"></a><div class="linenumber">2873</div><div style="width:6em;display:inline-block"></div>if&nbsp;(msgData)&nbsp;{
<a name="line2874"></a><div class="linenumber">2874</div><div style="width:8em;display:inline-block"></div>dataToShip.msgData&nbsp;=&nbsp;msgData;
<a name="line2875"></a><div class="linenumber">2875</div><div style="width:6em;display:inline-block"></div>}
<a name="line2876"></a><div class="linenumber">2876</div>
<a name="line2877"></a><div class="linenumber">2877</div><div style="width:6em;display:inline-block"></div>logDebug("sending&nbsp;socket&nbsp;message&nbsp;"&nbsp;+&nbsp;JSON.stringify(dataToShip));
<a name="line2878"></a><div class="linenumber">2878</div>
<a name="line2879"></a><div class="linenumber">2879</div><div style="width:6em;display:inline-block"></div>self.webSocket.json.emit("easyrtcCmd",&nbsp;dataToShip,
<a name="line2880"></a><div class="linenumber">2880</div><div style="width:10em;display:inline-block"></div>function(ackMsg)&nbsp;{
<a name="line2881"></a><div class="linenumber">2881</div><div style="width:12em;display:inline-block"></div>if&nbsp;(ackMsg.msgType&nbsp;!==&nbsp;"error")&nbsp;{
<a name="line2882"></a><div class="linenumber">2882</div><div style="width:14em;display:inline-block"></div>if&nbsp;(!ackMsg.hasOwnProperty("msgData"))&nbsp;{
<a name="line2883"></a><div class="linenumber">2883</div><div style="width:16em;display:inline-block"></div>ackMsg.msgData&nbsp;=&nbsp;null;
<a name="line2884"></a><div class="linenumber">2884</div><div style="width:14em;display:inline-block"></div>}
<a name="line2885"></a><div class="linenumber">2885</div><div style="width:14em;display:inline-block"></div>if&nbsp;(successCallback)&nbsp;{
<a name="line2886"></a><div class="linenumber">2886</div><div style="width:16em;display:inline-block"></div>successCallback(ackMsg.msgType,&nbsp;ackMsg.msgData);
<a name="line2887"></a><div class="linenumber">2887</div><div style="width:14em;display:inline-block"></div>}
<a name="line2888"></a><div class="linenumber">2888</div><div style="width:12em;display:inline-block"></div>}
<a name="line2889"></a><div class="linenumber">2889</div><div style="width:12em;display:inline-block"></div>else&nbsp;{
<a name="line2890"></a><div class="linenumber">2890</div><div style="width:14em;display:inline-block"></div>if&nbsp;(errorCallback)&nbsp;{
<a name="line2891"></a><div class="linenumber">2891</div><div style="width:16em;display:inline-block"></div>errorCallback(ackMsg.msgData.errorCode,&nbsp;ackMsg.msgData.errorText);
<a name="line2892"></a><div class="linenumber">2892</div><div style="width:14em;display:inline-block"></div>}
<a name="line2893"></a><div class="linenumber">2893</div><div style="width:14em;display:inline-block"></div>else&nbsp;{
<a name="line2894"></a><div class="linenumber">2894</div><div style="width:16em;display:inline-block"></div>self.showError(ackMsg.msgData.errorCode,&nbsp;ackMsg.msgData.errorText);
<a name="line2895"></a><div class="linenumber">2895</div><div style="width:14em;display:inline-block"></div>}
<a name="line2896"></a><div class="linenumber">2896</div><div style="width:12em;display:inline-block"></div>}
<a name="line2897"></a><div class="linenumber">2897</div><div style="width:10em;display:inline-block"></div>}
<a name="line2898"></a><div class="linenumber">2898</div><div style="width:6em;display:inline-block"></div>);
<a name="line2899"></a><div class="linenumber">2899</div><div style="width:4em;display:inline-block"></div>}
<a name="line2900"></a><div class="linenumber">2900</div><div style="width:2em;display:inline-block"></div>}
<a name="line2901"></a><div class="linenumber">2901</div>
<a name="line2902"></a><div class="linenumber">2902</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2903"></a><div class="linenumber">2903</div><div style="width:2em;display:inline-block"></div>//
<a name="line2904"></a><div class="linenumber">2904</div><div style="width:2em;display:inline-block"></div>//&nbsp;This&nbsp;function&nbsp;is&nbsp;used&nbsp;to&nbsp;send&nbsp;large&nbsp;messages.&nbsp;it&nbsp;sends&nbsp;messages&nbsp;that&nbsp;have&nbsp;a&nbsp;transfer&nbsp;field
<a name="line2905"></a><div class="linenumber">2905</div><div style="width:2em;display:inline-block"></div>//&nbsp;so&nbsp;that&nbsp;the&nbsp;receiver&nbsp;knows&nbsp;it's&nbsp;a&nbsp;transfer&nbsp;message.&nbsp;To&nbsp;differentiate&nbsp;the&nbsp;transfers,&nbsp;a
<a name="line2906"></a><div class="linenumber">2906</div><div style="width:2em;display:inline-block"></div>//&nbsp;transferId&nbsp;is&nbsp;generated&nbsp;and&nbsp;passed&nbsp;for&nbsp;each&nbsp;message.
<a name="line2907"></a><div class="linenumber">2907</div><div style="width:2em;display:inline-block"></div>//
<a name="line2908"></a><div class="linenumber">2908</div><div style="width:2em;display:inline-block"></div>var&nbsp;sendByChunkUidCounter&nbsp;=&nbsp;0;
<a name="line2909"></a><div class="linenumber">2909</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line2910"></a><div class="linenumber">2910</div><div style="width:2em;display:inline-block"></div>function&nbsp;sendByChunkHelper(destUser,&nbsp;msgData)&nbsp;{
<a name="line2911"></a><div class="linenumber">2911</div><div style="width:4em;display:inline-block"></div>var&nbsp;transferId&nbsp;=&nbsp;destUser&nbsp;+&nbsp;'-'&nbsp;+&nbsp;sendByChunkUidCounter++;
<a name="line2912"></a><div class="linenumber">2912</div>
<a name="line2913"></a><div class="linenumber">2913</div><div style="width:4em;display:inline-block"></div>var&nbsp;pos,&nbsp;len,&nbsp;startMessage,&nbsp;message,&nbsp;endMessage;
<a name="line2914"></a><div class="linenumber">2914</div><div style="width:4em;display:inline-block"></div>var&nbsp;numberOfChunks&nbsp;=&nbsp;Math.ceil(msgData.length&nbsp;/&nbsp;self.maxP2PMessageLength);
<a name="line2915"></a><div class="linenumber">2915</div><div style="width:4em;display:inline-block"></div>startMessage&nbsp;=&nbsp;{
<a name="line2916"></a><div class="linenumber">2916</div><div style="width:6em;display:inline-block"></div>transfer:&nbsp;'start',
<a name="line2917"></a><div class="linenumber">2917</div><div style="width:6em;display:inline-block"></div>transferId:&nbsp;transferId,
<a name="line2918"></a><div class="linenumber">2918</div><div style="width:6em;display:inline-block"></div>parts:&nbsp;numberOfChunks
<a name="line2919"></a><div class="linenumber">2919</div><div style="width:4em;display:inline-block"></div>};
<a name="line2920"></a><div class="linenumber">2920</div>
<a name="line2921"></a><div class="linenumber">2921</div><div style="width:4em;display:inline-block"></div>endMessage&nbsp;=&nbsp;{
<a name="line2922"></a><div class="linenumber">2922</div><div style="width:6em;display:inline-block"></div>transfer:&nbsp;'end',
<a name="line2923"></a><div class="linenumber">2923</div><div style="width:6em;display:inline-block"></div>transferId:&nbsp;transferId
<a name="line2924"></a><div class="linenumber">2924</div><div style="width:4em;display:inline-block"></div>};
<a name="line2925"></a><div class="linenumber">2925</div>
<a name="line2926"></a><div class="linenumber">2926</div><div style="width:4em;display:inline-block"></div>peerConns[destUser].dataChannelS.send(JSON.stringify(startMessage));
<a name="line2927"></a><div class="linenumber">2927</div>
<a name="line2928"></a><div class="linenumber">2928</div><div style="width:4em;display:inline-block"></div>for&nbsp;(pos&nbsp;=&nbsp;0,&nbsp;len&nbsp;=&nbsp;msgData.length;&nbsp;pos&nbsp;&lt;&nbsp;len;&nbsp;pos&nbsp;+=&nbsp;self.maxP2PMessageLength)&nbsp;{
<a name="line2929"></a><div class="linenumber">2929</div><div style="width:6em;display:inline-block"></div>message&nbsp;=&nbsp;{
<a name="line2930"></a><div class="linenumber">2930</div><div style="width:8em;display:inline-block"></div>transferId:&nbsp;transferId,
<a name="line2931"></a><div class="linenumber">2931</div><div style="width:8em;display:inline-block"></div>data:&nbsp;msgData.substr(pos,&nbsp;self.maxP2PMessageLength),
<a name="line2932"></a><div class="linenumber">2932</div><div style="width:8em;display:inline-block"></div>transfer:&nbsp;'chunk'
<a name="line2933"></a><div class="linenumber">2933</div><div style="width:6em;display:inline-block"></div>};
<a name="line2934"></a><div class="linenumber">2934</div><div style="width:6em;display:inline-block"></div>peerConns[destUser].dataChannelS.send(JSON.stringify(message));
<a name="line2935"></a><div class="linenumber">2935</div><div style="width:4em;display:inline-block"></div>}
<a name="line2936"></a><div class="linenumber">2936</div>
<a name="line2937"></a><div class="linenumber">2937</div><div style="width:4em;display:inline-block"></div>peerConns[destUser].dataChannelS.send(JSON.stringify(endMessage));
<a name="line2938"></a><div class="linenumber">2938</div><div style="width:2em;display:inline-block"></div>}
<a name="line2939"></a><div class="linenumber">2939</div>
<a name="line2940"></a><div class="linenumber">2940</div><div style="width:2em;display:inline-block"></div>/**
<a name="line2941"></a><div class="linenumber">2941</div><div style="width:2em;display:inline-block"></div>*Sends&nbsp;data&nbsp;to&nbsp;another&nbsp;user&nbsp;using&nbsp;previously&nbsp;established&nbsp;data&nbsp;channel.&nbsp;This&nbsp;method&nbsp;will
<a name="line2942"></a><div class="linenumber">2942</div><div style="width:2em;display:inline-block"></div>*&nbsp;fail&nbsp;if&nbsp;no&nbsp;data&nbsp;channel&nbsp;has&nbsp;been&nbsp;established&nbsp;yet.&nbsp;Unlike&nbsp;the&nbsp;easyrtc.sendWS&nbsp;method,
<a name="line2943"></a><div class="linenumber">2943</div><div style="width:2em;display:inline-block"></div>*&nbsp;you&nbsp;can't&nbsp;send&nbsp;a&nbsp;dictionary,&nbsp;convert&nbsp;dictionaries&nbsp;to&nbsp;strings&nbsp;using&nbsp;JSON.stringify&nbsp;first.
<a name="line2944"></a><div class="linenumber">2944</div><div style="width:2em;display:inline-block"></div>*&nbsp;What&nbsp;data&nbsp;types&nbsp;you&nbsp;can&nbsp;send,&nbsp;and&nbsp;how&nbsp;large&nbsp;a&nbsp;data&nbsp;type&nbsp;depends&nbsp;on&nbsp;your&nbsp;browser.
<a name="line2945"></a><div class="linenumber">2945</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;destUser&nbsp;(an&nbsp;easyrtcid)
<a name="line2946"></a><div class="linenumber">2946</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;msgType&nbsp;-&nbsp;the&nbsp;type&nbsp;of&nbsp;message&nbsp;being&nbsp;sent&nbsp;(application&nbsp;specific).
<a name="line2947"></a><div class="linenumber">2947</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;msgData&nbsp;-&nbsp;a&nbsp;JSONable&nbsp;object.
<a name="line2948"></a><div class="linenumber">2948</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2949"></a><div class="linenumber">2949</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.sendDataP2P(someEasyrtcid,&nbsp;"roomData",&nbsp;{room:499,&nbsp;bldgNum:'asd'});
<a name="line2950"></a><div class="linenumber">2950</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2951"></a><div class="linenumber">2951</div><div style="width:2em;display:inline-block"></div>this.sendDataP2P&nbsp;=&nbsp;function(destUser,&nbsp;msgType,&nbsp;msgData)&nbsp;{
<a name="line2952"></a><div class="linenumber">2952</div>
<a name="line2953"></a><div class="linenumber">2953</div><div style="width:4em;display:inline-block"></div>var&nbsp;flattenedData&nbsp;=&nbsp;JSON.stringify({msgType:&nbsp;msgType,&nbsp;msgData:&nbsp;msgData});
<a name="line2954"></a><div class="linenumber">2954</div><div style="width:4em;display:inline-block"></div>logDebug("sending&nbsp;p2p&nbsp;message&nbsp;to&nbsp;"&nbsp;+&nbsp;destUser&nbsp;+&nbsp;"&nbsp;with&nbsp;data="&nbsp;+&nbsp;JSON.stringify(flattenedData));
<a name="line2955"></a><div class="linenumber">2955</div>
<a name="line2956"></a><div class="linenumber">2956</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[destUser])&nbsp;{
<a name="line2957"></a><div class="linenumber">2957</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Attempt&nbsp;to&nbsp;send&nbsp;data&nbsp;peer&nbsp;to&nbsp;peer&nbsp;without&nbsp;a&nbsp;connection&nbsp;to&nbsp;"&nbsp;+&nbsp;destUser&nbsp;+&nbsp;'&nbsp;first.');
<a name="line2958"></a><div class="linenumber">2958</div><div style="width:4em;display:inline-block"></div>}
<a name="line2959"></a><div class="linenumber">2959</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(!peerConns[destUser].dataChannelS)&nbsp;{
<a name="line2960"></a><div class="linenumber">2960</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Attempt&nbsp;to&nbsp;send&nbsp;data&nbsp;peer&nbsp;to&nbsp;peer&nbsp;without&nbsp;establishing&nbsp;a&nbsp;data&nbsp;channel&nbsp;to&nbsp;"&nbsp;+&nbsp;destUser&nbsp;+&nbsp;'&nbsp;first.');
<a name="line2961"></a><div class="linenumber">2961</div><div style="width:4em;display:inline-block"></div>}
<a name="line2962"></a><div class="linenumber">2962</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(!peerConns[destUser].dataChannelReady)&nbsp;{
<a name="line2963"></a><div class="linenumber">2963</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Attempt&nbsp;to&nbsp;use&nbsp;data&nbsp;channel&nbsp;to&nbsp;"&nbsp;+&nbsp;destUser&nbsp;+&nbsp;"&nbsp;before&nbsp;it's&nbsp;ready&nbsp;to&nbsp;send.");
<a name="line2964"></a><div class="linenumber">2964</div><div style="width:4em;display:inline-block"></div>}
<a name="line2965"></a><div class="linenumber">2965</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line2966"></a><div class="linenumber">2966</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line2967"></a><div class="linenumber">2967</div><div style="width:8em;display:inline-block"></div>if&nbsp;(flattenedData.length&nbsp;&gt;&nbsp;self.maxP2PMessageLength)&nbsp;{
<a name="line2968"></a><div class="linenumber">2968</div><div style="width:10em;display:inline-block"></div>sendByChunkHelper(destUser,&nbsp;flattenedData);
<a name="line2969"></a><div class="linenumber">2969</div><div style="width:8em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line2970"></a><div class="linenumber">2970</div><div style="width:10em;display:inline-block"></div>peerConns[destUser].dataChannelS.send(flattenedData);
<a name="line2971"></a><div class="linenumber">2971</div><div style="width:8em;display:inline-block"></div>}
<a name="line2972"></a><div class="linenumber">2972</div><div style="width:6em;display:inline-block"></div>}&nbsp;catch&nbsp;(sendDataErr)&nbsp;{
<a name="line2973"></a><div class="linenumber">2973</div><div style="width:8em;display:inline-block"></div>logDebug("sendDataP2P&nbsp;error:&nbsp;",&nbsp;sendDataErr);
<a name="line2974"></a><div class="linenumber">2974</div><div style="width:8em;display:inline-block"></div>throw&nbsp;sendDataErr;
<a name="line2975"></a><div class="linenumber">2975</div><div style="width:6em;display:inline-block"></div>}
<a name="line2976"></a><div class="linenumber">2976</div><div style="width:4em;display:inline-block"></div>}
<a name="line2977"></a><div class="linenumber">2977</div><div style="width:2em;display:inline-block"></div>};
<a name="line2978"></a><div class="linenumber">2978</div>
<a name="line2979"></a><div class="linenumber">2979</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sends&nbsp;data&nbsp;to&nbsp;another&nbsp;user&nbsp;using&nbsp;websockets.&nbsp;The&nbsp;easyrtc.sendServerMessage&nbsp;or&nbsp;easyrtc.sendPeerMessage&nbsp;methods
<a name="line2980"></a><div class="linenumber">2980</div><div style="width:2em;display:inline-block"></div>*&nbsp;are&nbsp;wrappers&nbsp;for&nbsp;this&nbsp;method;&nbsp;application&nbsp;code&nbsp;should&nbsp;use&nbsp;them&nbsp;instead.
<a name="line2981"></a><div class="linenumber">2981</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;destination&nbsp;-&nbsp;either&nbsp;a&nbsp;string&nbsp;containing&nbsp;the&nbsp;easyrtcId&nbsp;of&nbsp;the&nbsp;other&nbsp;user,&nbsp;or&nbsp;an&nbsp;object&nbsp;containing&nbsp;some&nbsp;subset&nbsp;of&nbsp;the&nbsp;following&nbsp;fields:&nbsp;targetEasyrtcid,&nbsp;targetGroup,&nbsp;targetRoom.
<a name="line2982"></a><div class="linenumber">2982</div><div style="width:2em;display:inline-block"></div>*&nbsp;Specifying&nbsp;multiple&nbsp;fields&nbsp;restricts&nbsp;the&nbsp;scope&nbsp;of&nbsp;the&nbsp;destination&nbsp;(operates&nbsp;as&nbsp;a&nbsp;logical&nbsp;AND,&nbsp;not&nbsp;a&nbsp;logical&nbsp;OR).
<a name="line2983"></a><div class="linenumber">2983</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;msgType&nbsp;-the&nbsp;type&nbsp;of&nbsp;message&nbsp;being&nbsp;sent&nbsp;(application&nbsp;specific).
<a name="line2984"></a><div class="linenumber">2984</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;msgData&nbsp;-&nbsp;a&nbsp;JSONable&nbsp;object.
<a name="line2985"></a><div class="linenumber">2985</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;ackhandler&nbsp;-&nbsp;by&nbsp;default,&nbsp;the&nbsp;ackhandler&nbsp;handles&nbsp;acknowledgments&nbsp;from&nbsp;the&nbsp;server&nbsp;that&nbsp;your&nbsp;message&nbsp;was&nbsp;delivered&nbsp;to&nbsp;it's&nbsp;destination.
<a name="line2986"></a><div class="linenumber">2986</div><div style="width:2em;display:inline-block"></div>*&nbsp;However,&nbsp;application&nbsp;logic&nbsp;in&nbsp;the&nbsp;server&nbsp;can&nbsp;over-ride&nbsp;this.&nbsp;If&nbsp;you&nbsp;leave&nbsp;this&nbsp;null,&nbsp;a&nbsp;stub&nbsp;ackHandler&nbsp;will&nbsp;be&nbsp;used.&nbsp;The&nbsp;ackHandler
<a name="line2987"></a><div class="linenumber">2987</div><div style="width:2em;display:inline-block"></div>*&nbsp;gets&nbsp;passed&nbsp;a&nbsp;message&nbsp;with&nbsp;the&nbsp;same&nbsp;msgType&nbsp;as&nbsp;your&nbsp;outgoing&nbsp;message,&nbsp;or&nbsp;a&nbsp;message&nbsp;type&nbsp;of&nbsp;"error"&nbsp;in&nbsp;which&nbsp;case
<a name="line2988"></a><div class="linenumber">2988</div><div style="width:2em;display:inline-block"></div>*&nbsp;msgData&nbsp;will&nbsp;contain&nbsp;a&nbsp;errorCode&nbsp;and&nbsp;errorText&nbsp;fields.
<a name="line2989"></a><div class="linenumber">2989</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line2990"></a><div class="linenumber">2990</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.sendDataWS(someEasyrtcid,&nbsp;"setPostalAddress",&nbsp;{room:499,&nbsp;bldgNum:'asd'},
<a name="line2991"></a><div class="linenumber">2991</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(ackMsg){
<a name="line2992"></a><div class="linenumber">2992</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("saw&nbsp;the&nbsp;following&nbsp;acknowledgment&nbsp;"&nbsp;+&nbsp;JSON.stringify(ackMsg));
<a name="line2993"></a><div class="linenumber">2993</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line2994"></a><div class="linenumber">2994</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;);
<a name="line2995"></a><div class="linenumber">2995</div><div style="width:2em;display:inline-block"></div>*/
<a name="line2996"></a><div class="linenumber">2996</div><div style="width:2em;display:inline-block"></div>this.sendDataWS&nbsp;=&nbsp;function(destination,&nbsp;msgType,&nbsp;msgData,&nbsp;ackhandler)&nbsp;{
<a name="line2997"></a><div class="linenumber">2997</div><div style="width:4em;display:inline-block"></div>logDebug("sending&nbsp;client&nbsp;message&nbsp;via&nbsp;websockets&nbsp;to&nbsp;"&nbsp;+&nbsp;destination&nbsp;+&nbsp;"&nbsp;with&nbsp;data="&nbsp;+&nbsp;JSON.stringify(msgData));
<a name="line2998"></a><div class="linenumber">2998</div>
<a name="line2999"></a><div class="linenumber">2999</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!ackhandler)&nbsp;{
<a name="line3000"></a><div class="linenumber">3000</div><div style="width:6em;display:inline-block"></div>ackhandler&nbsp;=&nbsp;function(msg)&nbsp;{
<a name="line3001"></a><div class="linenumber">3001</div><div style="width:8em;display:inline-block"></div>if&nbsp;(msg.msgType&nbsp;===&nbsp;"error")&nbsp;{
<a name="line3002"></a><div class="linenumber">3002</div><div style="width:10em;display:inline-block"></div>self.showError(msg.msgData.errorCode,&nbsp;msg.msgData.errorText);
<a name="line3003"></a><div class="linenumber">3003</div><div style="width:8em;display:inline-block"></div>}
<a name="line3004"></a><div class="linenumber">3004</div><div style="width:6em;display:inline-block"></div>};
<a name="line3005"></a><div class="linenumber">3005</div><div style="width:4em;display:inline-block"></div>}
<a name="line3006"></a><div class="linenumber">3006</div>
<a name="line3007"></a><div class="linenumber">3007</div><div style="width:4em;display:inline-block"></div>var&nbsp;outgoingMessage&nbsp;=&nbsp;{
<a name="line3008"></a><div class="linenumber">3008</div><div style="width:6em;display:inline-block"></div>msgType:&nbsp;msgType,
<a name="line3009"></a><div class="linenumber">3009</div><div style="width:6em;display:inline-block"></div>msgData:&nbsp;msgData
<a name="line3010"></a><div class="linenumber">3010</div><div style="width:4em;display:inline-block"></div>};
<a name="line3011"></a><div class="linenumber">3011</div>
<a name="line3012"></a><div class="linenumber">3012</div><div style="width:4em;display:inline-block"></div>if&nbsp;(destination)&nbsp;{
<a name="line3013"></a><div class="linenumber">3013</div><div style="width:6em;display:inline-block"></div>if&nbsp;(typeof&nbsp;destination&nbsp;===&nbsp;'string')&nbsp;{
<a name="line3014"></a><div class="linenumber">3014</div><div style="width:8em;display:inline-block"></div>outgoingMessage.targetEasyrtcid&nbsp;=&nbsp;destination;
<a name="line3015"></a><div class="linenumber">3015</div><div style="width:6em;display:inline-block"></div>}
<a name="line3016"></a><div class="linenumber">3016</div><div style="width:6em;display:inline-block"></div>else&nbsp;if&nbsp;(typeof&nbsp;destination&nbsp;===&nbsp;'object')&nbsp;{
<a name="line3017"></a><div class="linenumber">3017</div><div style="width:8em;display:inline-block"></div>if&nbsp;(destination.targetEasyrtcid)&nbsp;{
<a name="line3018"></a><div class="linenumber">3018</div><div style="width:10em;display:inline-block"></div>outgoingMessage.targetEasyrtcid&nbsp;=&nbsp;destination.targetEasyrtcid;
<a name="line3019"></a><div class="linenumber">3019</div><div style="width:8em;display:inline-block"></div>}
<a name="line3020"></a><div class="linenumber">3020</div><div style="width:8em;display:inline-block"></div>if&nbsp;(destination.targetRoom)&nbsp;{
<a name="line3021"></a><div class="linenumber">3021</div><div style="width:10em;display:inline-block"></div>outgoingMessage.targetRoom&nbsp;=&nbsp;destination.targetRoom;
<a name="line3022"></a><div class="linenumber">3022</div><div style="width:8em;display:inline-block"></div>}
<a name="line3023"></a><div class="linenumber">3023</div><div style="width:8em;display:inline-block"></div>if&nbsp;(destination.targetGroup)&nbsp;{
<a name="line3024"></a><div class="linenumber">3024</div><div style="width:10em;display:inline-block"></div>outgoingMessage.targetGroup&nbsp;=&nbsp;destination.targetGroup;
<a name="line3025"></a><div class="linenumber">3025</div><div style="width:8em;display:inline-block"></div>}
<a name="line3026"></a><div class="linenumber">3026</div><div style="width:6em;display:inline-block"></div>}
<a name="line3027"></a><div class="linenumber">3027</div><div style="width:4em;display:inline-block"></div>}
<a name="line3028"></a><div class="linenumber">3028</div>
<a name="line3029"></a><div class="linenumber">3029</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.webSocket)&nbsp;{
<a name="line3030"></a><div class="linenumber">3030</div><div style="width:6em;display:inline-block"></div>self.webSocket.json.emit("easyrtcMsg",&nbsp;outgoingMessage,&nbsp;ackhandler);
<a name="line3031"></a><div class="linenumber">3031</div><div style="width:4em;display:inline-block"></div>}
<a name="line3032"></a><div class="linenumber">3032</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line3033"></a><div class="linenumber">3033</div><div style="width:6em;display:inline-block"></div>logDebug("websocket&nbsp;failed&nbsp;because&nbsp;no&nbsp;connection&nbsp;to&nbsp;server");
<a name="line3034"></a><div class="linenumber">3034</div>
<a name="line3035"></a><div class="linenumber">3035</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Attempt&nbsp;to&nbsp;send&nbsp;message&nbsp;without&nbsp;a&nbsp;valid&nbsp;connection&nbsp;to&nbsp;the&nbsp;server.";
<a name="line3036"></a><div class="linenumber">3036</div><div style="width:4em;display:inline-block"></div>}
<a name="line3037"></a><div class="linenumber">3037</div><div style="width:2em;display:inline-block"></div>};
<a name="line3038"></a><div class="linenumber">3038</div>
<a name="line3039"></a><div class="linenumber">3039</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sends&nbsp;data&nbsp;to&nbsp;another&nbsp;user.&nbsp;This&nbsp;method&nbsp;uses&nbsp;data&nbsp;channels&nbsp;if&nbsp;one&nbsp;has&nbsp;been&nbsp;set&nbsp;up,&nbsp;or&nbsp;websockets&nbsp;otherwise.
<a name="line3040"></a><div class="linenumber">3040</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;destUser&nbsp;-&nbsp;a&nbsp;string&nbsp;containing&nbsp;the&nbsp;easyrtcId&nbsp;of&nbsp;the&nbsp;other&nbsp;user.
<a name="line3041"></a><div class="linenumber">3041</div><div style="width:2em;display:inline-block"></div>*&nbsp;Specifying&nbsp;multiple&nbsp;fields&nbsp;restricts&nbsp;the&nbsp;scope&nbsp;of&nbsp;the&nbsp;destination&nbsp;(operates&nbsp;as&nbsp;a&nbsp;logical&nbsp;AND,&nbsp;not&nbsp;a&nbsp;logical&nbsp;OR).
<a name="line3042"></a><div class="linenumber">3042</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;msgType&nbsp;-the&nbsp;type&nbsp;of&nbsp;message&nbsp;being&nbsp;sent&nbsp;(application&nbsp;specific).
<a name="line3043"></a><div class="linenumber">3043</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;msgData&nbsp;-&nbsp;a&nbsp;JSONable&nbsp;object.
<a name="line3044"></a><div class="linenumber">3044</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;ackHandler&nbsp;-&nbsp;a&nbsp;function&nbsp;which&nbsp;receives&nbsp;acknowledgments.&nbsp;May&nbsp;only&nbsp;be&nbsp;invoked&nbsp;in
<a name="line3045"></a><div class="linenumber">3045</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;the&nbsp;websocket&nbsp;case.
<a name="line3046"></a><div class="linenumber">3046</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line3047"></a><div class="linenumber">3047</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.sendData(someEasyrtcid,&nbsp;"roomData",&nbsp;&nbsp;{room:499,&nbsp;bldgNum:'asd'},
<a name="line3048"></a><div class="linenumber">3048</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;ackHandler(msgType,&nbsp;msgData);
<a name="line3049"></a><div class="linenumber">3049</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;);
<a name="line3050"></a><div class="linenumber">3050</div><div style="width:2em;display:inline-block"></div>*/
<a name="line3051"></a><div class="linenumber">3051</div><div style="width:2em;display:inline-block"></div>this.sendData&nbsp;=&nbsp;function(destUser,&nbsp;msgType,&nbsp;msgData,&nbsp;ackHandler)&nbsp;{
<a name="line3052"></a><div class="linenumber">3052</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[destUser]&nbsp;&amp;&amp;&nbsp;peerConns[destUser].dataChannelReady)&nbsp;{
<a name="line3053"></a><div class="linenumber">3053</div><div style="width:6em;display:inline-block"></div>self.sendDataP2P(destUser,&nbsp;msgType,&nbsp;msgData);
<a name="line3054"></a><div class="linenumber">3054</div><div style="width:4em;display:inline-block"></div>}
<a name="line3055"></a><div class="linenumber">3055</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line3056"></a><div class="linenumber">3056</div><div style="width:6em;display:inline-block"></div>self.sendDataWS(destUser,&nbsp;msgType,&nbsp;msgData,&nbsp;ackHandler);
<a name="line3057"></a><div class="linenumber">3057</div><div style="width:4em;display:inline-block"></div>}
<a name="line3058"></a><div class="linenumber">3058</div><div style="width:2em;display:inline-block"></div>};
<a name="line3059"></a><div class="linenumber">3059</div>
<a name="line3060"></a><div class="linenumber">3060</div><div style="width:2em;display:inline-block"></div>/**
<a name="line3061"></a><div class="linenumber">3061</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sends&nbsp;a&nbsp;message&nbsp;to&nbsp;another&nbsp;peer&nbsp;on&nbsp;the&nbsp;easyrtcMsg&nbsp;channel.
<a name="line3062"></a><div class="linenumber">3062</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;destination&nbsp;-&nbsp;either&nbsp;a&nbsp;string&nbsp;containing&nbsp;the&nbsp;easyrtcId&nbsp;of&nbsp;the&nbsp;other&nbsp;user,&nbsp;or&nbsp;an&nbsp;object&nbsp;containing&nbsp;some&nbsp;subset&nbsp;of&nbsp;the&nbsp;following&nbsp;fields:&nbsp;targetEasyrtcid,&nbsp;targetGroup,&nbsp;targetRoom.
<a name="line3063"></a><div class="linenumber">3063</div><div style="width:2em;display:inline-block"></div>*&nbsp;Specifying&nbsp;multiple&nbsp;fields&nbsp;restricts&nbsp;the&nbsp;scope&nbsp;of&nbsp;the&nbsp;destination&nbsp;(operates&nbsp;as&nbsp;a&nbsp;logical&nbsp;AND,&nbsp;not&nbsp;a&nbsp;logical&nbsp;OR).
<a name="line3064"></a><div class="linenumber">3064</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;msgType&nbsp;-&nbsp;the&nbsp;type&nbsp;of&nbsp;message&nbsp;being&nbsp;sent&nbsp;(application&nbsp;specific).
<a name="line3065"></a><div class="linenumber">3065</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;msgData&nbsp;-&nbsp;a&nbsp;JSONable&nbsp;object&nbsp;with&nbsp;the&nbsp;message&nbsp;contents.
<a name="line3066"></a><div class="linenumber">3066</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(String,&nbsp;Object)}&nbsp;successCB&nbsp;-&nbsp;a&nbsp;callback&nbsp;function&nbsp;with&nbsp;results&nbsp;from&nbsp;the&nbsp;server.
<a name="line3067"></a><div class="linenumber">3067</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(String,&nbsp;String)}&nbsp;failureCB&nbsp;-&nbsp;a&nbsp;callback&nbsp;function&nbsp;to&nbsp;handle&nbsp;errors.
<a name="line3068"></a><div class="linenumber">3068</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line3069"></a><div class="linenumber">3069</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.sendPeerMessage(otherUser,&nbsp;'offer_candy',&nbsp;{candy_name:'mars'},
<a name="line3070"></a><div class="linenumber">3070</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(msgType,&nbsp;msgBody&nbsp;){
<a name="line3071"></a><div class="linenumber">3071</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("message&nbsp;was&nbsp;sent");
<a name="line3072"></a><div class="linenumber">3072</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line3073"></a><div class="linenumber">3073</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorCode,&nbsp;errorText){
<a name="line3074"></a><div class="linenumber">3074</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("error&nbsp;was&nbsp;"&nbsp;+&nbsp;errorText);
<a name="line3075"></a><div class="linenumber">3075</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line3076"></a><div class="linenumber">3076</div><div style="width:2em;display:inline-block"></div>*/
<a name="line3077"></a><div class="linenumber">3077</div><div style="width:2em;display:inline-block"></div>this.sendPeerMessage&nbsp;=&nbsp;function(destination,&nbsp;msgType,&nbsp;msgData,&nbsp;successCB,&nbsp;failureCB)&nbsp;{
<a name="line3078"></a><div class="linenumber">3078</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!destination)&nbsp;{
<a name="line3079"></a><div class="linenumber">3079</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"destination&nbsp;was&nbsp;null&nbsp;in&nbsp;sendPeerMessage");
<a name="line3080"></a><div class="linenumber">3080</div><div style="width:4em;display:inline-block"></div>}
<a name="line3081"></a><div class="linenumber">3081</div>
<a name="line3082"></a><div class="linenumber">3082</div><div style="width:4em;display:inline-block"></div>logDebug("sending&nbsp;peer&nbsp;message&nbsp;"&nbsp;+&nbsp;JSON.stringify(msgData));
<a name="line3083"></a><div class="linenumber">3083</div>
<a name="line3084"></a><div class="linenumber">3084</div><div style="width:4em;display:inline-block"></div>function&nbsp;ackHandler(response)&nbsp;{
<a name="line3085"></a><div class="linenumber">3085</div><div style="width:6em;display:inline-block"></div>if&nbsp;(response.msgType&nbsp;===&nbsp;"error")&nbsp;{
<a name="line3086"></a><div class="linenumber">3086</div><div style="width:8em;display:inline-block"></div>if&nbsp;(failureCB)&nbsp;{
<a name="line3087"></a><div class="linenumber">3087</div><div style="width:10em;display:inline-block"></div>failureCB(response.msgData.errorCode,&nbsp;response.msgData.errorText);
<a name="line3088"></a><div class="linenumber">3088</div><div style="width:8em;display:inline-block"></div>}
<a name="line3089"></a><div class="linenumber">3089</div><div style="width:6em;display:inline-block"></div>}
<a name="line3090"></a><div class="linenumber">3090</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line3091"></a><div class="linenumber">3091</div><div style="width:8em;display:inline-block"></div>if&nbsp;(successCB)&nbsp;{
<a name="line3092"></a><div class="linenumber">3092</div><div style="width:10em;display:inline-block"></div>//&nbsp;firefox&nbsp;complains&nbsp;if&nbsp;you&nbsp;pass&nbsp;an&nbsp;undefined&nbsp;as&nbsp;an&nbsp;parameter.
<a name="line3093"></a><div class="linenumber">3093</div><div style="width:10em;display:inline-block"></div>successCB(response.msgType,&nbsp;response.msgData&nbsp;?&nbsp;response.msgData&nbsp;:&nbsp;null);
<a name="line3094"></a><div class="linenumber">3094</div><div style="width:8em;display:inline-block"></div>}
<a name="line3095"></a><div class="linenumber">3095</div><div style="width:6em;display:inline-block"></div>}
<a name="line3096"></a><div class="linenumber">3096</div><div style="width:4em;display:inline-block"></div>}
<a name="line3097"></a><div class="linenumber">3097</div>
<a name="line3098"></a><div class="linenumber">3098</div><div style="width:4em;display:inline-block"></div>self.sendDataWS(destination,&nbsp;msgType,&nbsp;msgData,&nbsp;ackHandler);
<a name="line3099"></a><div class="linenumber">3099</div><div style="width:2em;display:inline-block"></div>};
<a name="line3100"></a><div class="linenumber">3100</div>
<a name="line3101"></a><div class="linenumber">3101</div><div style="width:2em;display:inline-block"></div>/**
<a name="line3102"></a><div class="linenumber">3102</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sends&nbsp;a&nbsp;message&nbsp;to&nbsp;the&nbsp;application&nbsp;code&nbsp;in&nbsp;the&nbsp;server&nbsp;(ie,&nbsp;on&nbsp;the&nbsp;easyrtcMsg&nbsp;channel).
<a name="line3103"></a><div class="linenumber">3103</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;msgType&nbsp;-&nbsp;the&nbsp;type&nbsp;of&nbsp;message&nbsp;being&nbsp;sent&nbsp;(application&nbsp;specific).
<a name="line3104"></a><div class="linenumber">3104</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;msgData&nbsp;-&nbsp;a&nbsp;JSONable&nbsp;object&nbsp;with&nbsp;the&nbsp;message&nbsp;contents.
<a name="line3105"></a><div class="linenumber">3105</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(String,&nbsp;Object)}&nbsp;successCB&nbsp;-&nbsp;a&nbsp;callback&nbsp;function&nbsp;with&nbsp;results&nbsp;from&nbsp;the&nbsp;server.
<a name="line3106"></a><div class="linenumber">3106</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(String,&nbsp;String)}&nbsp;failureCB&nbsp;-&nbsp;a&nbsp;callback&nbsp;function&nbsp;to&nbsp;handle&nbsp;errors.
<a name="line3107"></a><div class="linenumber">3107</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line3108"></a><div class="linenumber">3108</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.sendServerMessage('get_candy',&nbsp;{candy_name:'mars'},
<a name="line3109"></a><div class="linenumber">3109</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(msgType,&nbsp;msgData&nbsp;){
<a name="line3110"></a><div class="linenumber">3110</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("got&nbsp;candy&nbsp;count&nbsp;of&nbsp;"&nbsp;+&nbsp;msgData.barCount);
<a name="line3111"></a><div class="linenumber">3111</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line3112"></a><div class="linenumber">3112</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorCode,&nbsp;errorText){
<a name="line3113"></a><div class="linenumber">3113</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("error&nbsp;was&nbsp;"&nbsp;+&nbsp;errorText);
<a name="line3114"></a><div class="linenumber">3114</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line3115"></a><div class="linenumber">3115</div><div style="width:2em;display:inline-block"></div>*/
<a name="line3116"></a><div class="linenumber">3116</div><div style="width:2em;display:inline-block"></div>this.sendServerMessage&nbsp;=&nbsp;function(msgType,&nbsp;msgData,&nbsp;successCB,&nbsp;failureCB)&nbsp;{
<a name="line3117"></a><div class="linenumber">3117</div>
<a name="line3118"></a><div class="linenumber">3118</div><div style="width:4em;display:inline-block"></div>var&nbsp;dataToShip&nbsp;=&nbsp;{msgType:&nbsp;msgType,&nbsp;msgData:&nbsp;msgData};
<a name="line3119"></a><div class="linenumber">3119</div><div style="width:4em;display:inline-block"></div>logDebug("sending&nbsp;server&nbsp;message&nbsp;"&nbsp;+&nbsp;JSON.stringify(dataToShip));
<a name="line3120"></a><div class="linenumber">3120</div>
<a name="line3121"></a><div class="linenumber">3121</div><div style="width:4em;display:inline-block"></div>function&nbsp;ackhandler(response)&nbsp;{
<a name="line3122"></a><div class="linenumber">3122</div><div style="width:6em;display:inline-block"></div>if&nbsp;(response.msgType&nbsp;===&nbsp;"error")&nbsp;{
<a name="line3123"></a><div class="linenumber">3123</div><div style="width:8em;display:inline-block"></div>if&nbsp;(failureCB)&nbsp;{
<a name="line3124"></a><div class="linenumber">3124</div><div style="width:10em;display:inline-block"></div>failureCB(response.msgData.errorCode,&nbsp;response.msgData.errorText);
<a name="line3125"></a><div class="linenumber">3125</div><div style="width:8em;display:inline-block"></div>}
<a name="line3126"></a><div class="linenumber">3126</div><div style="width:6em;display:inline-block"></div>}
<a name="line3127"></a><div class="linenumber">3127</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line3128"></a><div class="linenumber">3128</div><div style="width:8em;display:inline-block"></div>if&nbsp;(successCB)&nbsp;{
<a name="line3129"></a><div class="linenumber">3129</div><div style="width:10em;display:inline-block"></div>successCB(response.msgType,&nbsp;response.msgData&nbsp;?&nbsp;response.msgData&nbsp;:&nbsp;null);
<a name="line3130"></a><div class="linenumber">3130</div><div style="width:8em;display:inline-block"></div>}
<a name="line3131"></a><div class="linenumber">3131</div><div style="width:6em;display:inline-block"></div>}
<a name="line3132"></a><div class="linenumber">3132</div><div style="width:4em;display:inline-block"></div>}
<a name="line3133"></a><div class="linenumber">3133</div>
<a name="line3134"></a><div class="linenumber">3134</div><div style="width:4em;display:inline-block"></div>self.sendDataWS(null,&nbsp;msgType,&nbsp;msgData,&nbsp;ackhandler);
<a name="line3135"></a><div class="linenumber">3135</div><div style="width:2em;display:inline-block"></div>};
<a name="line3136"></a><div class="linenumber">3136</div>
<a name="line3137"></a><div class="linenumber">3137</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Sends&nbsp;the&nbsp;server&nbsp;a&nbsp;request&nbsp;for&nbsp;the&nbsp;list&nbsp;of&nbsp;rooms&nbsp;the&nbsp;user&nbsp;can&nbsp;see.
<a name="line3138"></a><div class="linenumber">3138</div><div style="width:2em;display:inline-block"></div>*&nbsp;You&nbsp;must&nbsp;have&nbsp;already&nbsp;be&nbsp;connected&nbsp;to&nbsp;use&nbsp;this&nbsp;function.
<a name="line3139"></a><div class="linenumber">3139</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(Object)}&nbsp;callback&nbsp;-&nbsp;on&nbsp;success,&nbsp;this&nbsp;function&nbsp;is&nbsp;called&nbsp;with&nbsp;a&nbsp;map&nbsp;of&nbsp;the&nbsp;form&nbsp;&nbsp;{&nbsp;roomName:{"roomName":String,&nbsp;"numberClients":&nbsp;Number}}.
<a name="line3140"></a><div class="linenumber">3140</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;roomName&nbsp;appears&nbsp;as&nbsp;both&nbsp;the&nbsp;key&nbsp;to&nbsp;the&nbsp;map,&nbsp;and&nbsp;as&nbsp;the&nbsp;value&nbsp;of&nbsp;the&nbsp;"roomName"&nbsp;field.
<a name="line3141"></a><div class="linenumber">3141</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{function(String,&nbsp;String)}&nbsp;errorCallback&nbsp;&nbsp;&nbsp;is&nbsp;called&nbsp;on&nbsp;failure.&nbsp;It&nbsp;gets&nbsp;an&nbsp;errorCode&nbsp;and&nbsp;errorText&nbsp;as&nbsp;it's&nbsp;too&nbsp;arguments.
<a name="line3142"></a><div class="linenumber">3142</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line3143"></a><div class="linenumber">3143</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.getRoomList(
<a name="line3144"></a><div class="linenumber">3144</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(roomList){
<a name="line3145"></a><div class="linenumber">3145</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(roomName&nbsp;in&nbsp;roomList){
<a name="line3146"></a><div class="linenumber">3146</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("saw&nbsp;room&nbsp;"&nbsp;+&nbsp;roomName);
<a name="line3147"></a><div class="linenumber">3147</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line3148"></a><div class="linenumber">3148</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line3149"></a><div class="linenumber">3149</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorCode,&nbsp;errorText){
<a name="line3150"></a><div class="linenumber">3150</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.showError(errorCode,&nbsp;errorText);
<a name="line3151"></a><div class="linenumber">3151</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line3152"></a><div class="linenumber">3152</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;);
<a name="line3153"></a><div class="linenumber">3153</div><div style="width:2em;display:inline-block"></div>*/
<a name="line3154"></a><div class="linenumber">3154</div><div style="width:2em;display:inline-block"></div>this.getRoomList&nbsp;=&nbsp;function(callback,&nbsp;errorCallback)&nbsp;{
<a name="line3155"></a><div class="linenumber">3155</div><div style="width:4em;display:inline-block"></div>sendSignalling(null,&nbsp;"getRoomList",&nbsp;null,
<a name="line3156"></a><div class="linenumber">3156</div><div style="width:8em;display:inline-block"></div>function(msgType,&nbsp;msgData)&nbsp;{
<a name="line3157"></a><div class="linenumber">3157</div><div style="width:10em;display:inline-block"></div>callback(msgData.roomList);
<a name="line3158"></a><div class="linenumber">3158</div><div style="width:8em;display:inline-block"></div>},
<a name="line3159"></a><div class="linenumber">3159</div><div style="width:8em;display:inline-block"></div>function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line3160"></a><div class="linenumber">3160</div><div style="width:10em;display:inline-block"></div>if&nbsp;(errorCallback)&nbsp;{
<a name="line3161"></a><div class="linenumber">3161</div><div style="width:12em;display:inline-block"></div>errorCallback(errorCode,&nbsp;errorText);
<a name="line3162"></a><div class="linenumber">3162</div><div style="width:10em;display:inline-block"></div>}
<a name="line3163"></a><div class="linenumber">3163</div><div style="width:10em;display:inline-block"></div>else&nbsp;{
<a name="line3164"></a><div class="linenumber">3164</div><div style="width:12em;display:inline-block"></div>self.showError(errorCode,&nbsp;errorText);
<a name="line3165"></a><div class="linenumber">3165</div><div style="width:10em;display:inline-block"></div>}
<a name="line3166"></a><div class="linenumber">3166</div><div style="width:8em;display:inline-block"></div>}
<a name="line3167"></a><div class="linenumber">3167</div><div style="width:4em;display:inline-block"></div>);
<a name="line3168"></a><div class="linenumber">3168</div><div style="width:2em;display:inline-block"></div>};
<a name="line3169"></a><div class="linenumber">3169</div>
<a name="line3170"></a><div class="linenumber">3170</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Value&nbsp;returned&nbsp;by&nbsp;easyrtc.getConnectStatus&nbsp;if&nbsp;the&nbsp;other&nbsp;user&nbsp;isn't&nbsp;connected&nbsp;to&nbsp;us.&nbsp;*/
<a name="line3171"></a><div class="linenumber">3171</div><div style="width:2em;display:inline-block"></div>this.NOT_CONNECTED&nbsp;=&nbsp;"not&nbsp;connected";
<a name="line3172"></a><div class="linenumber">3172</div>
<a name="line3173"></a><div class="linenumber">3173</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Value&nbsp;returned&nbsp;by&nbsp;easyrtc.getConnectStatus&nbsp;if&nbsp;the&nbsp;other&nbsp;user&nbsp;is&nbsp;in&nbsp;the&nbsp;process&nbsp;of&nbsp;getting&nbsp;connected&nbsp;*/
<a name="line3174"></a><div class="linenumber">3174</div><div style="width:2em;display:inline-block"></div>this.BECOMING_CONNECTED&nbsp;=&nbsp;"connection&nbsp;in&nbsp;progress&nbsp;to&nbsp;us.";
<a name="line3175"></a><div class="linenumber">3175</div>
<a name="line3176"></a><div class="linenumber">3176</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Value&nbsp;returned&nbsp;by&nbsp;easyrtc.getConnectStatus&nbsp;if&nbsp;the&nbsp;other&nbsp;user&nbsp;is&nbsp;connected&nbsp;to&nbsp;us.&nbsp;*/
<a name="line3177"></a><div class="linenumber">3177</div><div style="width:2em;display:inline-block"></div>this.IS_CONNECTED&nbsp;=&nbsp;"is&nbsp;connected";
<a name="line3178"></a><div class="linenumber">3178</div>
<a name="line3179"></a><div class="linenumber">3179</div><div style="width:2em;display:inline-block"></div>/**
<a name="line3180"></a><div class="linenumber">3180</div><div style="width:2em;display:inline-block"></div>*&nbsp;Check&nbsp;if&nbsp;the&nbsp;client&nbsp;has&nbsp;a&nbsp;peer-2-peer&nbsp;connection&nbsp;to&nbsp;another&nbsp;user.
<a name="line3181"></a><div class="linenumber">3181</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;return&nbsp;values&nbsp;are&nbsp;text&nbsp;strings&nbsp;so&nbsp;you&nbsp;can&nbsp;use&nbsp;them&nbsp;in&nbsp;debugging&nbsp;output.
<a name="line3182"></a><div class="linenumber">3182</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{String}&nbsp;otherUser&nbsp;-&nbsp;the&nbsp;easyrtcid&nbsp;of&nbsp;the&nbsp;other&nbsp;user.
<a name="line3183"></a><div class="linenumber">3183</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@return&nbsp;{String}&nbsp;one&nbsp;of&nbsp;the&nbsp;following&nbsp;values:&nbsp;easyrtc.NOT_CONNECTED,&nbsp;easyrtc.BECOMING_CONNECTED,&nbsp;easyrtc.IS_CONNECTED
<a name="line3184"></a><div class="linenumber">3184</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@example
<a name="line3185"></a><div class="linenumber">3185</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;easyrtc.getConnectStatus(otherEasyrtcid)&nbsp;==&nbsp;easyrtc.NOT_CONNECTED&nbsp;){
<a name="line3186"></a><div class="linenumber">3186</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.call(otherEasyrtcid,
<a name="line3187"></a><div class="linenumber">3187</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(){&nbsp;console.log("success");&nbsp;},
<a name="line3188"></a><div class="linenumber">3188</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(){&nbsp;console.log("failure");&nbsp;});
<a name="line3189"></a><div class="linenumber">3189</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line3190"></a><div class="linenumber">3190</div><div style="width:2em;display:inline-block"></div>*/
<a name="line3191"></a><div class="linenumber">3191</div><div style="width:2em;display:inline-block"></div>this.getConnectStatus&nbsp;=&nbsp;function(otherUser)&nbsp;{
<a name="line3192"></a><div class="linenumber">3192</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns.hasOwnProperty(otherUser))&nbsp;{
<a name="line3193"></a><div class="linenumber">3193</div><div style="width:6em;display:inline-block"></div>return&nbsp;self.NOT_CONNECTED;
<a name="line3194"></a><div class="linenumber">3194</div><div style="width:4em;display:inline-block"></div>}
<a name="line3195"></a><div class="linenumber">3195</div><div style="width:4em;display:inline-block"></div>var&nbsp;peer&nbsp;=&nbsp;peerConns[otherUser];
<a name="line3196"></a><div class="linenumber">3196</div><div style="width:4em;display:inline-block"></div>if&nbsp;((peer.sharingAudio&nbsp;||&nbsp;peer.sharingVideo)&nbsp;&amp;&amp;&nbsp;!peer.startedAV)&nbsp;{
<a name="line3197"></a><div class="linenumber">3197</div><div style="width:6em;display:inline-block"></div>return&nbsp;self.BECOMING_CONNECTED;
<a name="line3198"></a><div class="linenumber">3198</div><div style="width:4em;display:inline-block"></div>}
<a name="line3199"></a><div class="linenumber">3199</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(peer.sharingData&nbsp;&amp;&amp;&nbsp;!peer.dataChannelReady)&nbsp;{
<a name="line3200"></a><div class="linenumber">3200</div><div style="width:6em;display:inline-block"></div>return&nbsp;self.BECOMING_CONNECTED;
<a name="line3201"></a><div class="linenumber">3201</div><div style="width:4em;display:inline-block"></div>}
<a name="line3202"></a><div class="linenumber">3202</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line3203"></a><div class="linenumber">3203</div><div style="width:6em;display:inline-block"></div>return&nbsp;self.IS_CONNECTED;
<a name="line3204"></a><div class="linenumber">3204</div><div style="width:4em;display:inline-block"></div>}
<a name="line3205"></a><div class="linenumber">3205</div><div style="width:2em;display:inline-block"></div>};
<a name="line3206"></a><div class="linenumber">3206</div>
<a name="line3207"></a><div class="linenumber">3207</div><div style="width:2em;display:inline-block"></div>/**
<a name="line3208"></a><div class="linenumber">3208</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line3209"></a><div class="linenumber">3209</div><div style="width:2em;display:inline-block"></div>*/
<a name="line3210"></a><div class="linenumber">3210</div><div style="width:2em;display:inline-block"></div>function&nbsp;buildPeerConstraints()&nbsp;{
<a name="line3211"></a><div class="linenumber">3211</div><div style="width:4em;display:inline-block"></div>var&nbsp;options&nbsp;=&nbsp;[];
<a name="line3212"></a><div class="linenumber">3212</div><div style="width:4em;display:inline-block"></div>options.push({'DtlsSrtpKeyAgreement':&nbsp;'true'});&nbsp;//&nbsp;for&nbsp;interoperability
<a name="line3213"></a><div class="linenumber">3213</div><div style="width:4em;display:inline-block"></div>return&nbsp;{optional:&nbsp;options};
<a name="line3214"></a><div class="linenumber">3214</div><div style="width:2em;display:inline-block"></div>}
<a name="line3215"></a><div class="linenumber">3215</div>
<a name="line3216"></a><div class="linenumber">3216</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3217"></a><div class="linenumber">3217</div><div style="width:2em;display:inline-block"></div>function&nbsp;sendQueuedCandidates(peer,&nbsp;onSignalSuccess,&nbsp;onSignalFailure)&nbsp;{
<a name="line3218"></a><div class="linenumber">3218</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line3219"></a><div class="linenumber">3219</div><div style="width:4em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;peerConns[peer].candidatesToSend.length;&nbsp;i++)&nbsp;{
<a name="line3220"></a><div class="linenumber">3220</div><div style="width:6em;display:inline-block"></div>sendSignalling(
<a name="line3221"></a><div class="linenumber">3221</div><div style="width:10em;display:inline-block"></div>peer,
<a name="line3222"></a><div class="linenumber">3222</div><div style="width:10em;display:inline-block"></div>"candidate",
<a name="line3223"></a><div class="linenumber">3223</div><div style="width:10em;display:inline-block"></div>peerConns[peer].candidatesToSend[i],
<a name="line3224"></a><div class="linenumber">3224</div><div style="width:10em;display:inline-block"></div>onSignalSuccess,
<a name="line3225"></a><div class="linenumber">3225</div><div style="width:10em;display:inline-block"></div>onSignalFailure
<a name="line3226"></a><div class="linenumber">3226</div><div style="width:10em;display:inline-block"></div>);
<a name="line3227"></a><div class="linenumber">3227</div><div style="width:4em;display:inline-block"></div>}
<a name="line3228"></a><div class="linenumber">3228</div><div style="width:2em;display:inline-block"></div>}
<a name="line3229"></a><div class="linenumber">3229</div>
<a name="line3230"></a><div class="linenumber">3230</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3231"></a><div class="linenumber">3231</div><div style="width:2em;display:inline-block"></div>//
<a name="line3232"></a><div class="linenumber">3232</div><div style="width:2em;display:inline-block"></div>//&nbsp;This&nbsp;function&nbsp;calls&nbsp;the&nbsp;users&nbsp;onStreamClosed&nbsp;handler,&nbsp;passing&nbsp;it&nbsp;the&nbsp;easyrtcid&nbsp;of&nbsp;the&nbsp;peer,&nbsp;the&nbsp;stream&nbsp;itself,
<a name="line3233"></a><div class="linenumber">3233</div><div style="width:2em;display:inline-block"></div>//&nbsp;and&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;stream.
<a name="line3234"></a><div class="linenumber">3234</div><div style="width:2em;display:inline-block"></div>//
<a name="line3235"></a><div class="linenumber">3235</div><div style="width:2em;display:inline-block"></div>function&nbsp;emitOnStreamClosed(easyrtcid,&nbsp;stream)&nbsp;{
<a name="line3236"></a><div class="linenumber">3236</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[easyrtcid])&nbsp;{
<a name="line3237"></a><div class="linenumber">3237</div><div style="width:6em;display:inline-block"></div>return;
<a name="line3238"></a><div class="linenumber">3238</div><div style="width:4em;display:inline-block"></div>}
<a name="line3239"></a><div class="linenumber">3239</div><div style="width:4em;display:inline-block"></div>var&nbsp;streamName;
<a name="line3240"></a><div class="linenumber">3240</div><div style="width:4em;display:inline-block"></div>var&nbsp;id;
<a name="line3241"></a><div class="linenumber">3241</div><div style="width:4em;display:inline-block"></div>if&nbsp;(stream.id)&nbsp;{
<a name="line3242"></a><div class="linenumber">3242</div><div style="width:6em;display:inline-block"></div>id&nbsp;=&nbsp;stream.id;
<a name="line3243"></a><div class="linenumber">3243</div><div style="width:4em;display:inline-block"></div>}
<a name="line3244"></a><div class="linenumber">3244</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line3245"></a><div class="linenumber">3245</div><div style="width:6em;display:inline-block"></div>id&nbsp;=&nbsp;"default";
<a name="line3246"></a><div class="linenumber">3246</div><div style="width:4em;display:inline-block"></div>}
<a name="line3247"></a><div class="linenumber">3247</div><div style="width:4em;display:inline-block"></div>streamName&nbsp;=&nbsp;peerConns[easyrtcid].remoteStreamIdToName[id]&nbsp;||&nbsp;"default";
<a name="line3248"></a><div class="linenumber">3248</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[easyrtcid].liveRemoteStreams[streamName]&nbsp;&amp;&amp;
<a name="line3249"></a><div class="linenumber">3249</div><div style="width:6em;display:inline-block"></div>self.onStreamClosed)&nbsp;{
<a name="line3250"></a><div class="linenumber">3250</div><div style="width:6em;display:inline-block"></div>delete&nbsp;peerConns[easyrtcid].liveRemoteStreams[streamName];
<a name="line3251"></a><div class="linenumber">3251</div><div style="width:6em;display:inline-block"></div>self.onStreamClosed(easyrtcid,&nbsp;stream,&nbsp;streamName);
<a name="line3252"></a><div class="linenumber">3252</div><div style="width:4em;display:inline-block"></div>}
<a name="line3253"></a><div class="linenumber">3253</div><div style="width:4em;display:inline-block"></div>delete&nbsp;peerConns[easyrtcid].remoteStreamIdToName[id];
<a name="line3254"></a><div class="linenumber">3254</div><div style="width:2em;display:inline-block"></div>}
<a name="line3255"></a><div class="linenumber">3255</div>
<a name="line3256"></a><div class="linenumber">3256</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3257"></a><div class="linenumber">3257</div><div style="width:2em;display:inline-block"></div>function&nbsp;onRemoveStreamHelper(easyrtcid,&nbsp;stream)&nbsp;{
<a name="line3258"></a><div class="linenumber">3258</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[easyrtcid])&nbsp;{
<a name="line3259"></a><div class="linenumber">3259</div><div style="width:6em;display:inline-block"></div>emitOnStreamClosed(easyrtcid,&nbsp;stream);
<a name="line3260"></a><div class="linenumber">3260</div><div style="width:6em;display:inline-block"></div>updateConfigurationInfo();
<a name="line3261"></a><div class="linenumber">3261</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[easyrtcid].pc)&nbsp;{
<a name="line3262"></a><div class="linenumber">3262</div><div style="width:8em;display:inline-block"></div>try&nbsp;{
<a name="line3263"></a><div class="linenumber">3263</div><div style="width:10em;display:inline-block"></div>peerConns[easyrtcid].pc.removeStream(stream);
<a name="line3264"></a><div class="linenumber">3264</div><div style="width:8em;display:inline-block"></div>}&nbsp;catch(&nbsp;err)&nbsp;{}
<a name="line3265"></a><div class="linenumber">3265</div><div style="width:6em;display:inline-block"></div>}
<a name="line3266"></a><div class="linenumber">3266</div><div style="width:4em;display:inline-block"></div>}
<a name="line3267"></a><div class="linenumber">3267</div><div style="width:2em;display:inline-block"></div>}
<a name="line3268"></a><div class="linenumber">3268</div>
<a name="line3269"></a><div class="linenumber">3269</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3270"></a><div class="linenumber">3270</div><div style="width:2em;display:inline-block"></div>function&nbsp;buildDeltaRecord(added,&nbsp;deleted)&nbsp;{
<a name="line3271"></a><div class="linenumber">3271</div><div style="width:4em;display:inline-block"></div>function&nbsp;objectNotEmpty(obj)&nbsp;{
<a name="line3272"></a><div class="linenumber">3272</div><div style="width:6em;display:inline-block"></div>var&nbsp;i;
<a name="line3273"></a><div class="linenumber">3273</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;in&nbsp;obj)&nbsp;{
<a name="line3274"></a><div class="linenumber">3274</div><div style="width:8em;display:inline-block"></div>if&nbsp;(obj.hasOwnProperty(i))&nbsp;{
<a name="line3275"></a><div class="linenumber">3275</div><div style="width:10em;display:inline-block"></div>return&nbsp;true;
<a name="line3276"></a><div class="linenumber">3276</div><div style="width:8em;display:inline-block"></div>}
<a name="line3277"></a><div class="linenumber">3277</div><div style="width:6em;display:inline-block"></div>}
<a name="line3278"></a><div class="linenumber">3278</div><div style="width:6em;display:inline-block"></div>return&nbsp;false;
<a name="line3279"></a><div class="linenumber">3279</div><div style="width:4em;display:inline-block"></div>}
<a name="line3280"></a><div class="linenumber">3280</div>
<a name="line3281"></a><div class="linenumber">3281</div><div style="width:4em;display:inline-block"></div>var&nbsp;result&nbsp;=&nbsp;{};
<a name="line3282"></a><div class="linenumber">3282</div><div style="width:4em;display:inline-block"></div>if&nbsp;(objectNotEmpty(added))&nbsp;{
<a name="line3283"></a><div class="linenumber">3283</div><div style="width:6em;display:inline-block"></div>result.added&nbsp;=&nbsp;added;
<a name="line3284"></a><div class="linenumber">3284</div><div style="width:4em;display:inline-block"></div>}
<a name="line3285"></a><div class="linenumber">3285</div>
<a name="line3286"></a><div class="linenumber">3286</div><div style="width:4em;display:inline-block"></div>if&nbsp;(objectNotEmpty(deleted))&nbsp;{
<a name="line3287"></a><div class="linenumber">3287</div><div style="width:6em;display:inline-block"></div>result.deleted&nbsp;=&nbsp;deleted;
<a name="line3288"></a><div class="linenumber">3288</div><div style="width:4em;display:inline-block"></div>}
<a name="line3289"></a><div class="linenumber">3289</div>
<a name="line3290"></a><div class="linenumber">3290</div><div style="width:4em;display:inline-block"></div>if&nbsp;(objectNotEmpty(result))&nbsp;{
<a name="line3291"></a><div class="linenumber">3291</div><div style="width:6em;display:inline-block"></div>return&nbsp;result;
<a name="line3292"></a><div class="linenumber">3292</div><div style="width:4em;display:inline-block"></div>}
<a name="line3293"></a><div class="linenumber">3293</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line3294"></a><div class="linenumber">3294</div><div style="width:6em;display:inline-block"></div>return&nbsp;null;
<a name="line3295"></a><div class="linenumber">3295</div><div style="width:4em;display:inline-block"></div>}
<a name="line3296"></a><div class="linenumber">3296</div><div style="width:2em;display:inline-block"></div>}
<a name="line3297"></a><div class="linenumber">3297</div>
<a name="line3298"></a><div class="linenumber">3298</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3299"></a><div class="linenumber">3299</div><div style="width:2em;display:inline-block"></div>function&nbsp;findDeltas(oldVersion,&nbsp;newVersion)&nbsp;{
<a name="line3300"></a><div class="linenumber">3300</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line3301"></a><div class="linenumber">3301</div><div style="width:4em;display:inline-block"></div>var&nbsp;added&nbsp;=&nbsp;{},&nbsp;deleted&nbsp;=&nbsp;{};
<a name="line3302"></a><div class="linenumber">3302</div><div style="width:4em;display:inline-block"></div>var&nbsp;subPart;
<a name="line3303"></a><div class="linenumber">3303</div><div style="width:4em;display:inline-block"></div>for&nbsp;(i&nbsp;in&nbsp;newVersion)&nbsp;{
<a name="line3304"></a><div class="linenumber">3304</div><div style="width:6em;display:inline-block"></div>if&nbsp;(newVersion.hasOwnProperty(i))&nbsp;{
<a name="line3305"></a><div class="linenumber">3305</div><div style="width:8em;display:inline-block"></div>if&nbsp;(oldVersion&nbsp;===&nbsp;null&nbsp;||&nbsp;typeof&nbsp;oldVersion[i]&nbsp;===&nbsp;'undefined')&nbsp;{
<a name="line3306"></a><div class="linenumber">3306</div><div style="width:10em;display:inline-block"></div>added[i]&nbsp;=&nbsp;newVersion[i];
<a name="line3307"></a><div class="linenumber">3307</div><div style="width:8em;display:inline-block"></div>}
<a name="line3308"></a><div class="linenumber">3308</div><div style="width:8em;display:inline-block"></div>else&nbsp;if&nbsp;(typeof&nbsp;newVersion[i]&nbsp;===&nbsp;'object')&nbsp;{
<a name="line3309"></a><div class="linenumber">3309</div><div style="width:10em;display:inline-block"></div>subPart&nbsp;=&nbsp;findDeltas(oldVersion[i],&nbsp;newVersion[i]);
<a name="line3310"></a><div class="linenumber">3310</div><div style="width:10em;display:inline-block"></div>if&nbsp;(subPart&nbsp;!==&nbsp;null)&nbsp;{
<a name="line3311"></a><div class="linenumber">3311</div><div style="width:12em;display:inline-block"></div>added[i]&nbsp;=&nbsp;newVersion[i];
<a name="line3312"></a><div class="linenumber">3312</div><div style="width:10em;display:inline-block"></div>}
<a name="line3313"></a><div class="linenumber">3313</div><div style="width:8em;display:inline-block"></div>}
<a name="line3314"></a><div class="linenumber">3314</div><div style="width:8em;display:inline-block"></div>else&nbsp;if&nbsp;(newVersion[i]&nbsp;!==&nbsp;oldVersion[i])&nbsp;{
<a name="line3315"></a><div class="linenumber">3315</div><div style="width:10em;display:inline-block"></div>added[i]&nbsp;=&nbsp;newVersion[i];
<a name="line3316"></a><div class="linenumber">3316</div><div style="width:8em;display:inline-block"></div>}
<a name="line3317"></a><div class="linenumber">3317</div><div style="width:6em;display:inline-block"></div>}
<a name="line3318"></a><div class="linenumber">3318</div><div style="width:4em;display:inline-block"></div>}
<a name="line3319"></a><div class="linenumber">3319</div><div style="width:4em;display:inline-block"></div>for&nbsp;(i&nbsp;in&nbsp;oldVersion)&nbsp;{
<a name="line3320"></a><div class="linenumber">3320</div><div style="width:6em;display:inline-block"></div>if&nbsp;(newVersion.hasOwnProperty(i))&nbsp;{
<a name="line3321"></a><div class="linenumber">3321</div><div style="width:8em;display:inline-block"></div>if&nbsp;(typeof&nbsp;newVersion[i]&nbsp;===&nbsp;'undefined')&nbsp;{
<a name="line3322"></a><div class="linenumber">3322</div><div style="width:10em;display:inline-block"></div>deleted[i]&nbsp;=&nbsp;oldVersion[i];
<a name="line3323"></a><div class="linenumber">3323</div><div style="width:8em;display:inline-block"></div>}
<a name="line3324"></a><div class="linenumber">3324</div><div style="width:6em;display:inline-block"></div>}
<a name="line3325"></a><div class="linenumber">3325</div><div style="width:4em;display:inline-block"></div>}
<a name="line3326"></a><div class="linenumber">3326</div>
<a name="line3327"></a><div class="linenumber">3327</div><div style="width:4em;display:inline-block"></div>return&nbsp;buildDeltaRecord(added,&nbsp;deleted);
<a name="line3328"></a><div class="linenumber">3328</div><div style="width:2em;display:inline-block"></div>}
<a name="line3329"></a><div class="linenumber">3329</div>
<a name="line3330"></a><div class="linenumber">3330</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3331"></a><div class="linenumber">3331</div><div style="width:2em;display:inline-block"></div>//
<a name="line3332"></a><div class="linenumber">3332</div><div style="width:2em;display:inline-block"></div>//&nbsp;this&nbsp;function&nbsp;collects&nbsp;configuration&nbsp;info&nbsp;that&nbsp;will&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;server.
<a name="line3333"></a><div class="linenumber">3333</div><div style="width:2em;display:inline-block"></div>//&nbsp;It&nbsp;returns&nbsp;that&nbsp;information,&nbsp;leaving&nbsp;it&nbsp;the&nbsp;responsibility&nbsp;of&nbsp;the&nbsp;caller&nbsp;to
<a name="line3334"></a><div class="linenumber">3334</div><div style="width:2em;display:inline-block"></div>//&nbsp;do&nbsp;the&nbsp;actual&nbsp;sending.
<a name="line3335"></a><div class="linenumber">3335</div><div style="width:2em;display:inline-block"></div>//
<a name="line3336"></a><div class="linenumber">3336</div><div style="width:2em;display:inline-block"></div>function&nbsp;collectConfigurationInfo(/*&nbsp;forAuthentication&nbsp;*/)&nbsp;{
<a name="line3337"></a><div class="linenumber">3337</div><div style="width:4em;display:inline-block"></div>var&nbsp;p2pList&nbsp;=&nbsp;{};
<a name="line3338"></a><div class="linenumber">3338</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line3339"></a><div class="linenumber">3339</div><div style="width:4em;display:inline-block"></div>for&nbsp;(i&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line3340"></a><div class="linenumber">3340</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!peerConns.hasOwnProperty(i))&nbsp;{
<a name="line3341"></a><div class="linenumber">3341</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line3342"></a><div class="linenumber">3342</div><div style="width:6em;display:inline-block"></div>}
<a name="line3343"></a><div class="linenumber">3343</div><div style="width:6em;display:inline-block"></div>p2pList[i]&nbsp;=&nbsp;{
<a name="line3344"></a><div class="linenumber">3344</div><div style="width:8em;display:inline-block"></div>connectTime:&nbsp;peerConns[i].connectTime,
<a name="line3345"></a><div class="linenumber">3345</div><div style="width:8em;display:inline-block"></div>isInitiator:&nbsp;!!peerConns[i].isInitiator
<a name="line3346"></a><div class="linenumber">3346</div><div style="width:6em;display:inline-block"></div>};
<a name="line3347"></a><div class="linenumber">3347</div><div style="width:4em;display:inline-block"></div>}
<a name="line3348"></a><div class="linenumber">3348</div>
<a name="line3349"></a><div class="linenumber">3349</div><div style="width:4em;display:inline-block"></div>var&nbsp;newConfig&nbsp;=&nbsp;{
<a name="line3350"></a><div class="linenumber">3350</div><div style="width:6em;display:inline-block"></div>userSettings:&nbsp;{
<a name="line3351"></a><div class="linenumber">3351</div><div style="width:8em;display:inline-block"></div>sharingAudio:&nbsp;!!haveAudioVideo.audio,
<a name="line3352"></a><div class="linenumber">3352</div><div style="width:8em;display:inline-block"></div>sharingVideo:&nbsp;!!haveAudioVideo.video,
<a name="line3353"></a><div class="linenumber">3353</div><div style="width:8em;display:inline-block"></div>sharingData:&nbsp;!!dataEnabled,
<a name="line3354"></a><div class="linenumber">3354</div><div style="width:8em;display:inline-block"></div>nativeVideoWidth:&nbsp;self.nativeVideoWidth,
<a name="line3355"></a><div class="linenumber">3355</div><div style="width:8em;display:inline-block"></div>nativeVideoHeight:&nbsp;self.nativeVideoHeight,
<a name="line3356"></a><div class="linenumber">3356</div><div style="width:8em;display:inline-block"></div>windowWidth:&nbsp;window.innerWidth,
<a name="line3357"></a><div class="linenumber">3357</div><div style="width:8em;display:inline-block"></div>windowHeight:&nbsp;window.innerHeight,
<a name="line3358"></a><div class="linenumber">3358</div><div style="width:8em;display:inline-block"></div>screenWidth:&nbsp;window.screen.width,
<a name="line3359"></a><div class="linenumber">3359</div><div style="width:8em;display:inline-block"></div>screenHeight:&nbsp;window.screen.height,
<a name="line3360"></a><div class="linenumber">3360</div><div style="width:8em;display:inline-block"></div>cookieEnabled:&nbsp;navigator.cookieEnabled,
<a name="line3361"></a><div class="linenumber">3361</div><div style="width:8em;display:inline-block"></div>os:&nbsp;navigator.oscpu,
<a name="line3362"></a><div class="linenumber">3362</div><div style="width:8em;display:inline-block"></div>language:&nbsp;navigator.language
<a name="line3363"></a><div class="linenumber">3363</div><div style="width:6em;display:inline-block"></div>}
<a name="line3364"></a><div class="linenumber">3364</div><div style="width:4em;display:inline-block"></div>};
<a name="line3365"></a><div class="linenumber">3365</div>
<a name="line3366"></a><div class="linenumber">3366</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!isEmptyObj(p2pList))&nbsp;{
<a name="line3367"></a><div class="linenumber">3367</div><div style="width:6em;display:inline-block"></div>newConfig.p2pList&nbsp;=&nbsp;p2pList;
<a name="line3368"></a><div class="linenumber">3368</div><div style="width:4em;display:inline-block"></div>}
<a name="line3369"></a><div class="linenumber">3369</div>
<a name="line3370"></a><div class="linenumber">3370</div><div style="width:4em;display:inline-block"></div>return&nbsp;newConfig;
<a name="line3371"></a><div class="linenumber">3371</div><div style="width:2em;display:inline-block"></div>}
<a name="line3372"></a><div class="linenumber">3372</div>
<a name="line3373"></a><div class="linenumber">3373</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3374"></a><div class="linenumber">3374</div><div style="width:2em;display:inline-block"></div>function&nbsp;updateConfiguration()&nbsp;{
<a name="line3375"></a><div class="linenumber">3375</div>
<a name="line3376"></a><div class="linenumber">3376</div><div style="width:4em;display:inline-block"></div>var&nbsp;newConfig&nbsp;=&nbsp;collectConfigurationInfo(false);
<a name="line3377"></a><div class="linenumber">3377</div><div style="width:4em;display:inline-block"></div>//
<a name="line3378"></a><div class="linenumber">3378</div><div style="width:4em;display:inline-block"></div>//&nbsp;we&nbsp;need&nbsp;to&nbsp;give&nbsp;the&nbsp;getStats&nbsp;calls&nbsp;a&nbsp;chance&nbsp;to&nbsp;fish&nbsp;out&nbsp;the&nbsp;data.
<a name="line3379"></a><div class="linenumber">3379</div><div style="width:4em;display:inline-block"></div>//&nbsp;The&nbsp;longest&nbsp;I've&nbsp;seen&nbsp;it&nbsp;take&nbsp;is&nbsp;5&nbsp;milliseconds&nbsp;so&nbsp;100&nbsp;should&nbsp;be&nbsp;overkill.
<a name="line3380"></a><div class="linenumber">3380</div><div style="width:4em;display:inline-block"></div>//
<a name="line3381"></a><div class="linenumber">3381</div><div style="width:4em;display:inline-block"></div>var&nbsp;sendDeltas&nbsp;=&nbsp;function()&nbsp;{
<a name="line3382"></a><div class="linenumber">3382</div><div style="width:6em;display:inline-block"></div>var&nbsp;alteredData&nbsp;=&nbsp;findDeltas(oldConfig,&nbsp;newConfig);
<a name="line3383"></a><div class="linenumber">3383</div><div style="width:6em;display:inline-block"></div>//
<a name="line3384"></a><div class="linenumber">3384</div><div style="width:6em;display:inline-block"></div>//&nbsp;send&nbsp;all&nbsp;the&nbsp;configuration&nbsp;information&nbsp;that&nbsp;changes&nbsp;during&nbsp;the&nbsp;session
<a name="line3385"></a><div class="linenumber">3385</div><div style="width:6em;display:inline-block"></div>//
<a name="line3386"></a><div class="linenumber">3386</div><div style="width:6em;display:inline-block"></div>if&nbsp;(alteredData)&nbsp;{
<a name="line3387"></a><div class="linenumber">3387</div><div style="width:8em;display:inline-block"></div>logDebug("cfg="&nbsp;+&nbsp;JSON.stringify(alteredData.added));
<a name="line3388"></a><div class="linenumber">3388</div>
<a name="line3389"></a><div class="linenumber">3389</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.webSocket)&nbsp;{
<a name="line3390"></a><div class="linenumber">3390</div><div style="width:10em;display:inline-block"></div>sendSignalling(null,&nbsp;"setUserCfg",&nbsp;{setUserCfg:&nbsp;alteredData.added},&nbsp;null,&nbsp;null);
<a name="line3391"></a><div class="linenumber">3391</div><div style="width:8em;display:inline-block"></div>}
<a name="line3392"></a><div class="linenumber">3392</div><div style="width:6em;display:inline-block"></div>}
<a name="line3393"></a><div class="linenumber">3393</div><div style="width:6em;display:inline-block"></div>oldConfig&nbsp;=&nbsp;newConfig;
<a name="line3394"></a><div class="linenumber">3394</div><div style="width:4em;display:inline-block"></div>};
<a name="line3395"></a><div class="linenumber">3395</div><div style="width:4em;display:inline-block"></div>if&nbsp;(oldConfig&nbsp;===&nbsp;{})&nbsp;{
<a name="line3396"></a><div class="linenumber">3396</div><div style="width:6em;display:inline-block"></div>sendDeltas();
<a name="line3397"></a><div class="linenumber">3397</div><div style="width:4em;display:inline-block"></div>}
<a name="line3398"></a><div class="linenumber">3398</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line3399"></a><div class="linenumber">3399</div><div style="width:6em;display:inline-block"></div>setTimeout(sendDeltas,&nbsp;100);
<a name="line3400"></a><div class="linenumber">3400</div><div style="width:4em;display:inline-block"></div>}
<a name="line3401"></a><div class="linenumber">3401</div><div style="width:2em;display:inline-block"></div>}
<a name="line3402"></a><div class="linenumber">3402</div>
<a name="line3403"></a><div class="linenumber">3403</div><div style="width:2em;display:inline-block"></div>//&nbsp;Parse&nbsp;the&nbsp;uint32&nbsp;PRIORITY&nbsp;field&nbsp;into&nbsp;its&nbsp;constituent&nbsp;parts&nbsp;from&nbsp;RFC&nbsp;5245,
<a name="line3404"></a><div class="linenumber">3404</div><div style="width:2em;display:inline-block"></div>//&nbsp;type&nbsp;preference,&nbsp;local&nbsp;preference,&nbsp;and&nbsp;(256&nbsp;-&nbsp;component&nbsp;ID).
<a name="line3405"></a><div class="linenumber">3405</div><div style="width:2em;display:inline-block"></div>//&nbsp;ex:&nbsp;126&nbsp;|&nbsp;32252&nbsp;|&nbsp;255&nbsp;(126&nbsp;is&nbsp;host&nbsp;preference,&nbsp;255&nbsp;is&nbsp;component&nbsp;ID&nbsp;1)
<a name="line3406"></a><div class="linenumber">3406</div><div style="width:2em;display:inline-block"></div>function&nbsp;formatPriority(priority)&nbsp;{
<a name="line3407"></a><div class="linenumber">3407</div><div style="width:4em;display:inline-block"></div>var&nbsp;s&nbsp;=&nbsp;'';
<a name="line3408"></a><div class="linenumber">3408</div><div style="width:4em;display:inline-block"></div>s&nbsp;+=&nbsp;(priority&nbsp;&gt;&gt;&nbsp;24);
<a name="line3409"></a><div class="linenumber">3409</div><div style="width:4em;display:inline-block"></div>s&nbsp;+=&nbsp;'&nbsp;|&nbsp;';
<a name="line3410"></a><div class="linenumber">3410</div><div style="width:4em;display:inline-block"></div>s&nbsp;+=&nbsp;(priority&nbsp;&gt;&gt;&nbsp;8)&nbsp;&amp;&nbsp;0xFFFF;
<a name="line3411"></a><div class="linenumber">3411</div><div style="width:4em;display:inline-block"></div>s&nbsp;+=&nbsp;'&nbsp;|&nbsp;';
<a name="line3412"></a><div class="linenumber">3412</div><div style="width:4em;display:inline-block"></div>s&nbsp;+=&nbsp;priority&nbsp;&amp;&nbsp;0xFF;
<a name="line3413"></a><div class="linenumber">3413</div><div style="width:4em;display:inline-block"></div>return&nbsp;s;
<a name="line3414"></a><div class="linenumber">3414</div><div style="width:2em;display:inline-block"></div>}
<a name="line3415"></a><div class="linenumber">3415</div>
<a name="line3416"></a><div class="linenumber">3416</div><div style="width:2em;display:inline-block"></div>//&nbsp;Parse&nbsp;a&nbsp;candidate:foo&nbsp;string&nbsp;into&nbsp;an&nbsp;object,&nbsp;for&nbsp;easier&nbsp;use&nbsp;by&nbsp;other&nbsp;methods.
<a name="line3417"></a><div class="linenumber">3417</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3418"></a><div class="linenumber">3418</div><div style="width:2em;display:inline-block"></div>function&nbsp;parseCandidate(text)&nbsp;{
<a name="line3419"></a><div class="linenumber">3419</div><div style="width:4em;display:inline-block"></div>var&nbsp;candidateStr&nbsp;=&nbsp;'candidate:';
<a name="line3420"></a><div class="linenumber">3420</div><div style="width:4em;display:inline-block"></div>var&nbsp;pos&nbsp;=&nbsp;text.indexOf(candidateStr)&nbsp;+&nbsp;candidateStr.length;
<a name="line3421"></a><div class="linenumber">3421</div><div style="width:4em;display:inline-block"></div>var&nbsp;fields&nbsp;=&nbsp;text.substr(pos).split('&nbsp;');
<a name="line3422"></a><div class="linenumber">3422</div><div style="width:4em;display:inline-block"></div>return&nbsp;{
<a name="line3423"></a><div class="linenumber">3423</div><div style="width:6em;display:inline-block"></div>'component':&nbsp;fields[1],
<a name="line3424"></a><div class="linenumber">3424</div><div style="width:6em;display:inline-block"></div>'type':&nbsp;fields[7],
<a name="line3425"></a><div class="linenumber">3425</div><div style="width:6em;display:inline-block"></div>'foundation':&nbsp;fields[0],
<a name="line3426"></a><div class="linenumber">3426</div><div style="width:6em;display:inline-block"></div>'protocol':&nbsp;fields[2],
<a name="line3427"></a><div class="linenumber">3427</div><div style="width:6em;display:inline-block"></div>'address':&nbsp;fields[4],
<a name="line3428"></a><div class="linenumber">3428</div><div style="width:6em;display:inline-block"></div>'port':&nbsp;fields[5],
<a name="line3429"></a><div class="linenumber">3429</div><div style="width:6em;display:inline-block"></div>'priority':&nbsp;formatPriority(fields[3])
<a name="line3430"></a><div class="linenumber">3430</div><div style="width:4em;display:inline-block"></div>};
<a name="line3431"></a><div class="linenumber">3431</div><div style="width:2em;display:inline-block"></div>}
<a name="line3432"></a><div class="linenumber">3432</div>
<a name="line3433"></a><div class="linenumber">3433</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3434"></a><div class="linenumber">3434</div><div style="width:2em;display:inline-block"></div>function&nbsp;processCandicate(candicate)&nbsp;{
<a name="line3435"></a><div class="linenumber">3435</div><div style="width:4em;display:inline-block"></div>self._candicates&nbsp;=&nbsp;self._candicates&nbsp;||&nbsp;[];
<a name="line3436"></a><div class="linenumber">3436</div><div style="width:4em;display:inline-block"></div>self._candicates.push(parseCandidate(candicate));
<a name="line3437"></a><div class="linenumber">3437</div><div style="width:2em;display:inline-block"></div>}
<a name="line3438"></a><div class="linenumber">3438</div>
<a name="line3439"></a><div class="linenumber">3439</div><div style="width:2em;display:inline-block"></div>function&nbsp;processAddedStream(otherUser,&nbsp;theStream)&nbsp;{
<a name="line3440"></a><div class="linenumber">3440</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[otherUser]&nbsp;||&nbsp;&nbsp;peerConns[otherUser].cancelled)&nbsp;{
<a name="line3441"></a><div class="linenumber">3441</div><div style="width:6em;display:inline-block"></div>return;
<a name="line3442"></a><div class="linenumber">3442</div><div style="width:4em;display:inline-block"></div>}
<a name="line3443"></a><div class="linenumber">3443</div>
<a name="line3444"></a><div class="linenumber">3444</div><div style="width:4em;display:inline-block"></div>var&nbsp;peerConn&nbsp;=&nbsp;peerConns[otherUser];
<a name="line3445"></a><div class="linenumber">3445</div>
<a name="line3446"></a><div class="linenumber">3446</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConn.startedAV)&nbsp;{
<a name="line3447"></a><div class="linenumber">3447</div><div style="width:6em;display:inline-block"></div>peerConn.startedAV&nbsp;=&nbsp;true;
<a name="line3448"></a><div class="linenumber">3448</div><div style="width:6em;display:inline-block"></div>peerConn.sharingAudio&nbsp;=&nbsp;haveAudioVideo.audio;
<a name="line3449"></a><div class="linenumber">3449</div><div style="width:6em;display:inline-block"></div>peerConn.sharingVideo&nbsp;=&nbsp;haveAudioVideo.video;
<a name="line3450"></a><div class="linenumber">3450</div><div style="width:6em;display:inline-block"></div>peerConn.connectTime&nbsp;=&nbsp;new&nbsp;Date().getTime();
<a name="line3451"></a><div class="linenumber">3451</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConn.callSuccessCB)&nbsp;{
<a name="line3452"></a><div class="linenumber">3452</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConn.sharingAudio&nbsp;||&nbsp;peerConn.sharingVideo)&nbsp;{
<a name="line3453"></a><div class="linenumber">3453</div><div style="width:10em;display:inline-block"></div>peerConn.callSuccessCB(otherUser,&nbsp;"audiovideo");
<a name="line3454"></a><div class="linenumber">3454</div><div style="width:8em;display:inline-block"></div>}
<a name="line3455"></a><div class="linenumber">3455</div><div style="width:6em;display:inline-block"></div>}
<a name="line3456"></a><div class="linenumber">3456</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.audioEnabled&nbsp;||&nbsp;self.videoEnabled)&nbsp;{
<a name="line3457"></a><div class="linenumber">3457</div><div style="width:8em;display:inline-block"></div>updateConfiguration();
<a name="line3458"></a><div class="linenumber">3458</div><div style="width:6em;display:inline-block"></div>}
<a name="line3459"></a><div class="linenumber">3459</div><div style="width:4em;display:inline-block"></div>}
<a name="line3460"></a><div class="linenumber">3460</div>
<a name="line3461"></a><div class="linenumber">3461</div><div style="width:4em;display:inline-block"></div>var&nbsp;remoteName&nbsp;=&nbsp;getNameOfRemoteStream(otherUser,&nbsp;theStream.id&nbsp;||&nbsp;"default");
<a name="line3462"></a><div class="linenumber">3462</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!remoteName)&nbsp;{
<a name="line3463"></a><div class="linenumber">3463</div><div style="width:6em;display:inline-block"></div>remoteName&nbsp;=&nbsp;"default";
<a name="line3464"></a><div class="linenumber">3464</div><div style="width:4em;display:inline-block"></div>}
<a name="line3465"></a><div class="linenumber">3465</div><div style="width:4em;display:inline-block"></div>peerConn.remoteStreamIdToName[theStream.id&nbsp;||&nbsp;"default"]&nbsp;=&nbsp;remoteName;
<a name="line3466"></a><div class="linenumber">3466</div><div style="width:4em;display:inline-block"></div>peerConn.liveRemoteStreams[remoteName]&nbsp;=&nbsp;true;
<a name="line3467"></a><div class="linenumber">3467</div><div style="width:4em;display:inline-block"></div>theStream.streamName&nbsp;=&nbsp;remoteName;
<a name="line3468"></a><div class="linenumber">3468</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.streamAcceptor)&nbsp;{
<a name="line3469"></a><div class="linenumber">3469</div><div style="width:6em;display:inline-block"></div>self.streamAcceptor(otherUser,&nbsp;theStream,&nbsp;remoteName);
<a name="line3470"></a><div class="linenumber">3470</div><div style="width:6em;display:inline-block"></div>//
<a name="line3471"></a><div class="linenumber">3471</div><div style="width:6em;display:inline-block"></div>//&nbsp;Inform&nbsp;the&nbsp;other&nbsp;user&nbsp;that&nbsp;the&nbsp;stream&nbsp;they&nbsp;provided&nbsp;has&nbsp;been&nbsp;received.
<a name="line3472"></a><div class="linenumber">3472</div><div style="width:6em;display:inline-block"></div>//&nbsp;This&nbsp;should&nbsp;be&nbsp;moved&nbsp;into&nbsp;signalling&nbsp;at&nbsp;some&nbsp;point
<a name="line3473"></a><div class="linenumber">3473</div><div style="width:6em;display:inline-block"></div>//
<a name="line3474"></a><div class="linenumber">3474</div><div style="width:6em;display:inline-block"></div>self.sendDataWS(otherUser,&nbsp;"easyrtc_streamReceived",&nbsp;{streamName:remoteName},function(){});
<a name="line3475"></a><div class="linenumber">3475</div><div style="width:4em;display:inline-block"></div>}
<a name="line3476"></a><div class="linenumber">3476</div><div style="width:2em;display:inline-block"></div>}
<a name="line3477"></a><div class="linenumber">3477</div>
<a name="line3478"></a><div class="linenumber">3478</div><div style="width:2em;display:inline-block"></div>function&nbsp;processAddedTrack(otherUser,&nbsp;peerStreams)&nbsp;{
<a name="line3479"></a><div class="linenumber">3479</div>
<a name="line3480"></a><div class="linenumber">3480</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[otherUser]&nbsp;||&nbsp;&nbsp;peerConns[otherUser].cancelled)&nbsp;{
<a name="line3481"></a><div class="linenumber">3481</div><div style="width:6em;display:inline-block"></div>return;
<a name="line3482"></a><div class="linenumber">3482</div><div style="width:4em;display:inline-block"></div>}
<a name="line3483"></a><div class="linenumber">3483</div>
<a name="line3484"></a><div class="linenumber">3484</div><div style="width:4em;display:inline-block"></div>var&nbsp;peerConn&nbsp;=&nbsp;peerConns[otherUser];
<a name="line3485"></a><div class="linenumber">3485</div><div style="width:4em;display:inline-block"></div>peerConn.trackTimers&nbsp;=&nbsp;peerConn.trackTimers&nbsp;||&nbsp;{};
<a name="line3486"></a><div class="linenumber">3486</div>
<a name="line3487"></a><div class="linenumber">3487</div><div style="width:4em;display:inline-block"></div>//&nbsp;easyrtc&nbsp;thinks&nbsp;in&nbsp;terms&nbsp;of&nbsp;streams,&nbsp;not&nbsp;tracks.
<a name="line3488"></a><div class="linenumber">3488</div><div style="width:4em;display:inline-block"></div>//&nbsp;so&nbsp;we'll&nbsp;add&nbsp;a&nbsp;timeout&nbsp;when&nbsp;the&nbsp;first&nbsp;track&nbsp;event
<a name="line3489"></a><div class="linenumber">3489</div><div style="width:4em;display:inline-block"></div>//&nbsp;fires.&nbsp;Firefox&nbsp;produces&nbsp;two&nbsp;events&nbsp;(one&nbsp;of&nbsp;type&nbsp;"video",
<a name="line3490"></a><div class="linenumber">3490</div><div style="width:4em;display:inline-block"></div>//&nbsp;and&nbsp;one&nbsp;of&nbsp;type&nbsp;"audio".
<a name="line3491"></a><div class="linenumber">3491</div>
<a name="line3492"></a><div class="linenumber">3492</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;i&nbsp;=&nbsp;0,&nbsp;l&nbsp;=&nbsp;peerStreams.length;&nbsp;i&nbsp;&lt;&nbsp;l;&nbsp;i++)&nbsp;{
<a name="line3493"></a><div class="linenumber">3493</div><div style="width:6em;display:inline-block"></div>var&nbsp;peerStream&nbsp;=&nbsp;peerStreams[i],
<a name="line3494"></a><div class="linenumber">3494</div><div style="width:8em;display:inline-block"></div>streamId&nbsp;=&nbsp;peerStream.id&nbsp;||&nbsp;"default";
<a name="line3495"></a><div class="linenumber">3495</div><div style="width:6em;display:inline-block"></div>clearTimeout(peerConn.trackTimers[streamId]);
<a name="line3496"></a><div class="linenumber">3496</div><div style="width:6em;display:inline-block"></div>peerConn.trackTimers[streamId]&nbsp;=&nbsp;setTimeout(function(peerStream)&nbsp;{
<a name="line3497"></a><div class="linenumber">3497</div><div style="width:7em;display:inline-block"></div>processAddedStream(peerConn,&nbsp;otherUser,&nbsp;peerStream);
<a name="line3498"></a><div class="linenumber">3498</div><div style="width:6em;display:inline-block"></div>}.bind(peerStream),&nbsp;100);&nbsp;//&nbsp;Bind&nbsp;peerStream
<a name="line3499"></a><div class="linenumber">3499</div><div style="width:4em;display:inline-block"></div>}
<a name="line3500"></a><div class="linenumber">3500</div><div style="width:2em;display:inline-block"></div>}
<a name="line3501"></a><div class="linenumber">3501</div>
<a name="line3502"></a><div class="linenumber">3502</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3503"></a><div class="linenumber">3503</div><div style="width:2em;display:inline-block"></div>//&nbsp;TODO&nbsp;split&nbsp;buildPeerConnection&nbsp;it&nbsp;more&nbsp;thant&nbsp;500&nbsp;lines
<a name="line3504"></a><div class="linenumber">3504</div><div style="width:2em;display:inline-block"></div>function&nbsp;buildPeerConnection(otherUser,&nbsp;isInitiator,&nbsp;failureCB,&nbsp;streamNames)&nbsp;{
<a name="line3505"></a><div class="linenumber">3505</div><div style="width:4em;display:inline-block"></div>var&nbsp;pc;
<a name="line3506"></a><div class="linenumber">3506</div><div style="width:4em;display:inline-block"></div>var&nbsp;message;
<a name="line3507"></a><div class="linenumber">3507</div><div style="width:4em;display:inline-block"></div>var&nbsp;newPeerConn;
<a name="line3508"></a><div class="linenumber">3508</div><div style="width:4em;display:inline-block"></div>var&nbsp;iceConfig&nbsp;=&nbsp;pc_config_to_use&nbsp;?&nbsp;pc_config_to_use&nbsp;:&nbsp;pc_config;
<a name="line3509"></a><div class="linenumber">3509</div>
<a name="line3510"></a><div class="linenumber">3510</div><div style="width:4em;display:inline-block"></div>logDebug("building&nbsp;peer&nbsp;connection&nbsp;to&nbsp;"&nbsp;+&nbsp;otherUser);
<a name="line3511"></a><div class="linenumber">3511</div>
<a name="line3512"></a><div class="linenumber">3512</div><div style="width:4em;display:inline-block"></div>//
<a name="line3513"></a><div class="linenumber">3513</div><div style="width:4em;display:inline-block"></div>//&nbsp;we&nbsp;don't&nbsp;support&nbsp;data&nbsp;channels&nbsp;on&nbsp;chrome&nbsp;versions&nbsp;&lt;&nbsp;31
<a name="line3514"></a><div class="linenumber">3514</div><div style="width:4em;display:inline-block"></div>//
<a name="line3515"></a><div class="linenumber">3515</div>
<a name="line3516"></a><div class="linenumber">3516</div><div style="width:4em;display:inline-block"></div>try&nbsp;{
<a name="line3517"></a><div class="linenumber">3517</div>
<a name="line3518"></a><div class="linenumber">3518</div><div style="width:6em;display:inline-block"></div>pc&nbsp;=&nbsp;self.createRTCPeerConnection(iceConfig,&nbsp;buildPeerConstraints());
<a name="line3519"></a><div class="linenumber">3519</div>
<a name="line3520"></a><div class="linenumber">3520</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!pc)&nbsp;{
<a name="line3521"></a><div class="linenumber">3521</div><div style="width:8em;display:inline-block"></div>message&nbsp;=&nbsp;"Unable&nbsp;to&nbsp;create&nbsp;PeerConnection&nbsp;object,&nbsp;check&nbsp;your&nbsp;ice&nbsp;configuration("&nbsp;+&nbsp;JSON.stringify(iceConfig)&nbsp;+&nbsp;")";
<a name="line3522"></a><div class="linenumber">3522</div><div style="width:8em;display:inline-block"></div>logDebug(message);
<a name="line3523"></a><div class="linenumber">3523</div><div style="width:8em;display:inline-block"></div>throw&nbsp;Error(message);
<a name="line3524"></a><div class="linenumber">3524</div><div style="width:6em;display:inline-block"></div>}
<a name="line3525"></a><div class="linenumber">3525</div>
<a name="line3526"></a><div class="linenumber">3526</div><div style="width:6em;display:inline-block"></div>//
<a name="line3527"></a><div class="linenumber">3527</div><div style="width:6em;display:inline-block"></div>//&nbsp;turn&nbsp;off&nbsp;data&nbsp;channel&nbsp;support&nbsp;if&nbsp;the&nbsp;browser&nbsp;doesn't&nbsp;support&nbsp;it.
<a name="line3528"></a><div class="linenumber">3528</div><div style="width:6em;display:inline-block"></div>//
<a name="line3529"></a><div class="linenumber">3529</div>
<a name="line3530"></a><div class="linenumber">3530</div><div style="width:6em;display:inline-block"></div>if&nbsp;(dataEnabled&nbsp;&amp;&amp;&nbsp;typeof&nbsp;pc.createDataChannel&nbsp;===&nbsp;'undefined')&nbsp;{
<a name="line3531"></a><div class="linenumber">3531</div><div style="width:8em;display:inline-block"></div>dataEnabled&nbsp;=&nbsp;false;
<a name="line3532"></a><div class="linenumber">3532</div><div style="width:6em;display:inline-block"></div>}
<a name="line3533"></a><div class="linenumber">3533</div>
<a name="line3534"></a><div class="linenumber">3534</div><div style="width:6em;display:inline-block"></div>pc.onnegotiationneeded&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3535"></a><div class="linenumber">3535</div><div style="width:8em;display:inline-block"></div>if&nbsp;(
<a name="line3536"></a><div class="linenumber">3536</div><div style="width:10em;display:inline-block"></div>peerConns[otherUser]&nbsp;&amp;&amp;
<a name="line3537"></a><div class="linenumber">3537</div><div style="width:12em;display:inline-block"></div>(peerConns[otherUser].enableNegotiateListener)
<a name="line3538"></a><div class="linenumber">3538</div><div style="width:8em;display:inline-block"></div>)&nbsp;{
<a name="line3539"></a><div class="linenumber">3539</div><div style="width:10em;display:inline-block"></div>pc.createOffer(function(sdp)&nbsp;{
<a name="line3540"></a><div class="linenumber">3540</div><div style="width:12em;display:inline-block"></div>if&nbsp;(sdpLocalFilter)&nbsp;{
<a name="line3541"></a><div class="linenumber">3541</div><div style="width:14em;display:inline-block"></div>sdp.sdp&nbsp;=&nbsp;sdpLocalFilter(sdp.sdp);
<a name="line3542"></a><div class="linenumber">3542</div><div style="width:12em;display:inline-block"></div>}
<a name="line3543"></a><div class="linenumber">3543</div><div style="width:12em;display:inline-block"></div>pc.setLocalDescription(sdp,&nbsp;function()&nbsp;{
<a name="line3544"></a><div class="linenumber">3544</div><div style="width:14em;display:inline-block"></div>self.sendPeerMessage(otherUser,&nbsp;"__addedMediaStream",&nbsp;{
<a name="line3545"></a><div class="linenumber">3545</div><div style="width:16em;display:inline-block"></div>sdp:&nbsp;sdp
<a name="line3546"></a><div class="linenumber">3546</div><div style="width:14em;display:inline-block"></div>});
<a name="line3547"></a><div class="linenumber">3547</div>
<a name="line3548"></a><div class="linenumber">3548</div><div style="width:12em;display:inline-block"></div>},&nbsp;function()&nbsp;{
<a name="line3549"></a><div class="linenumber">3549</div><div style="width:12em;display:inline-block"></div>});
<a name="line3550"></a><div class="linenumber">3550</div><div style="width:10em;display:inline-block"></div>},&nbsp;function(error)&nbsp;{
<a name="line3551"></a><div class="linenumber">3551</div><div style="width:12em;display:inline-block"></div>logDebug("unexpected&nbsp;error&nbsp;in&nbsp;creating&nbsp;offer");
<a name="line3552"></a><div class="linenumber">3552</div><div style="width:10em;display:inline-block"></div>});
<a name="line3553"></a><div class="linenumber">3553</div><div style="width:8em;display:inline-block"></div>}
<a name="line3554"></a><div class="linenumber">3554</div><div style="width:6em;display:inline-block"></div>};
<a name="line3555"></a><div class="linenumber">3555</div>
<a name="line3556"></a><div class="linenumber">3556</div><div style="width:6em;display:inline-block"></div>pc.onsignalingstatechange&nbsp;=&nbsp;function&nbsp;()&nbsp;{
<a name="line3557"></a><div class="linenumber">3557</div>
<a name="line3558"></a><div class="linenumber">3558</div><div style="width:8em;display:inline-block"></div>var&nbsp;eventTarget&nbsp;=&nbsp;event.currentTarget&nbsp;||&nbsp;event.target&nbsp;||&nbsp;pc,
<a name="line3559"></a><div class="linenumber">3559</div><div style="width:10em;display:inline-block"></div>signalingState&nbsp;=&nbsp;eventTarget.signalingState&nbsp;||&nbsp;'unknown';
<a name="line3560"></a><div class="linenumber">3560</div>
<a name="line3561"></a><div class="linenumber">3561</div><div style="width:8em;display:inline-block"></div>if&nbsp;(signalingStateChangeListener)&nbsp;{
<a name="line3562"></a><div class="linenumber">3562</div><div style="width:9em;display:inline-block"></div>signalingStateChangeListener(otherUser,&nbsp;eventTarget,&nbsp;signalingState);
<a name="line3563"></a><div class="linenumber">3563</div><div style="width:8em;display:inline-block"></div>}
<a name="line3564"></a><div class="linenumber">3564</div><div style="width:6em;display:inline-block"></div>};
<a name="line3565"></a><div class="linenumber">3565</div>
<a name="line3566"></a><div class="linenumber">3566</div><div style="width:6em;display:inline-block"></div>pc.oniceconnectionstatechange&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3567"></a><div class="linenumber">3567</div>
<a name="line3568"></a><div class="linenumber">3568</div><div style="width:8em;display:inline-block"></div>var&nbsp;eventTarget&nbsp;=&nbsp;event.currentTarget&nbsp;||&nbsp;event.target&nbsp;||&nbsp;pc,
<a name="line3569"></a><div class="linenumber">3569</div><div style="width:10em;display:inline-block"></div>connState&nbsp;=&nbsp;eventTarget.iceConnectionState&nbsp;||&nbsp;'unknown';
<a name="line3570"></a><div class="linenumber">3570</div>
<a name="line3571"></a><div class="linenumber">3571</div><div style="width:8em;display:inline-block"></div>if&nbsp;(iceConnectionStateChangeListener)&nbsp;{
<a name="line3572"></a><div class="linenumber">3572</div><div style="width:9em;display:inline-block"></div>iceConnectionStateChangeListener(otherUser,&nbsp;eventTarget,&nbsp;connState);
<a name="line3573"></a><div class="linenumber">3573</div><div style="width:8em;display:inline-block"></div>}
<a name="line3574"></a><div class="linenumber">3574</div>
<a name="line3575"></a><div class="linenumber">3575</div><div style="width:8em;display:inline-block"></div>switch&nbsp;(connState)&nbsp;{
<a name="line3576"></a><div class="linenumber">3576</div><div style="width:10em;display:inline-block"></div>case&nbsp;"connected":
<a name="line3577"></a><div class="linenumber">3577</div><div style="width:12em;display:inline-block"></div>if&nbsp;(self.onPeerOpen&nbsp;)&nbsp;{
<a name="line3578"></a><div class="linenumber">3578</div><div style="width:14em;display:inline-block"></div>self.onPeerOpen(otherUser);
<a name="line3579"></a><div class="linenumber">3579</div><div style="width:12em;display:inline-block"></div>}
<a name="line3580"></a><div class="linenumber">3580</div><div style="width:12em;display:inline-block"></div>if&nbsp;(peerConns[otherUser]&nbsp;&amp;&amp;&nbsp;peerConns[otherUser].callSuccessCB)&nbsp;{
<a name="line3581"></a><div class="linenumber">3581</div><div style="width:14em;display:inline-block"></div>peerConns[otherUser].callSuccessCB(otherUser,&nbsp;"connection");
<a name="line3582"></a><div class="linenumber">3582</div><div style="width:12em;display:inline-block"></div>}
<a name="line3583"></a><div class="linenumber">3583</div><div style="width:12em;display:inline-block"></div>break;
<a name="line3584"></a><div class="linenumber">3584</div><div style="width:10em;display:inline-block"></div>case&nbsp;"failed":
<a name="line3585"></a><div class="linenumber">3585</div><div style="width:12em;display:inline-block"></div>if&nbsp;(failureCB)&nbsp;{
<a name="line3586"></a><div class="linenumber">3586</div><div style="width:14em;display:inline-block"></div>failureCB(self.errCodes.NOVIABLEICE,&nbsp;"No&nbsp;usable&nbsp;STUN/TURN&nbsp;path");
<a name="line3587"></a><div class="linenumber">3587</div><div style="width:12em;display:inline-block"></div>}
<a name="line3588"></a><div class="linenumber">3588</div><div style="width:12em;display:inline-block"></div>delete&nbsp;peerConns[otherUser];
<a name="line3589"></a><div class="linenumber">3589</div><div style="width:12em;display:inline-block"></div>break;
<a name="line3590"></a><div class="linenumber">3590</div><div style="width:10em;display:inline-block"></div>case&nbsp;"disconnected":
<a name="line3591"></a><div class="linenumber">3591</div><div style="width:12em;display:inline-block"></div>if&nbsp;(self.onPeerFailing)&nbsp;{
<a name="line3592"></a><div class="linenumber">3592</div><div style="width:14em;display:inline-block"></div>self.onPeerFailing(otherUser);
<a name="line3593"></a><div class="linenumber">3593</div><div style="width:12em;display:inline-block"></div>}
<a name="line3594"></a><div class="linenumber">3594</div><div style="width:12em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3595"></a><div class="linenumber">3595</div><div style="width:14em;display:inline-block"></div>peerConns[otherUser].failing&nbsp;=&nbsp;Date.now();
<a name="line3596"></a><div class="linenumber">3596</div><div style="width:12em;display:inline-block"></div>}
<a name="line3597"></a><div class="linenumber">3597</div><div style="width:12em;display:inline-block"></div>break;
<a name="line3598"></a><div class="linenumber">3598</div>
<a name="line3599"></a><div class="linenumber">3599</div><div style="width:10em;display:inline-block"></div>case&nbsp;"closed":
<a name="line3600"></a><div class="linenumber">3600</div><div style="width:12em;display:inline-block"></div>if&nbsp;(self.onPeerClosed)&nbsp;{
<a name="line3601"></a><div class="linenumber">3601</div><div style="width:14em;display:inline-block"></div>self.onPeerClosed(otherUser);
<a name="line3602"></a><div class="linenumber">3602</div><div style="width:12em;display:inline-block"></div>}
<a name="line3603"></a><div class="linenumber">3603</div><div style="width:12em;display:inline-block"></div>break;
<a name="line3604"></a><div class="linenumber">3604</div><div style="width:10em;display:inline-block"></div>case&nbsp;"completed":
<a name="line3605"></a><div class="linenumber">3605</div><div style="width:12em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3606"></a><div class="linenumber">3606</div><div style="width:14em;display:inline-block"></div>if&nbsp;(peerConns[otherUser].failing&nbsp;&amp;&amp;&nbsp;self.onPeerRecovered)&nbsp;{
<a name="line3607"></a><div class="linenumber">3607</div><div style="width:16em;display:inline-block"></div>self.onPeerRecovered(otherUser,&nbsp;peerConns[otherUser].failing,&nbsp;Date.now());
<a name="line3608"></a><div class="linenumber">3608</div><div style="width:14em;display:inline-block"></div>}
<a name="line3609"></a><div class="linenumber">3609</div><div style="width:14em;display:inline-block"></div>delete&nbsp;peerConns[otherUser].failing;
<a name="line3610"></a><div class="linenumber">3610</div><div style="width:12em;display:inline-block"></div>}
<a name="line3611"></a><div class="linenumber">3611</div><div style="width:12em;display:inline-block"></div>break;
<a name="line3612"></a><div class="linenumber">3612</div><div style="width:8em;display:inline-block"></div>}
<a name="line3613"></a><div class="linenumber">3613</div><div style="width:6em;display:inline-block"></div>};
<a name="line3614"></a><div class="linenumber">3614</div>
<a name="line3615"></a><div class="linenumber">3615</div><div style="width:6em;display:inline-block"></div>pc.onconnection&nbsp;=&nbsp;function()&nbsp;{
<a name="line3616"></a><div class="linenumber">3616</div><div style="width:8em;display:inline-block"></div>logDebug("onconnection&nbsp;called&nbsp;prematurely");
<a name="line3617"></a><div class="linenumber">3617</div><div style="width:6em;display:inline-block"></div>};
<a name="line3618"></a><div class="linenumber">3618</div>
<a name="line3619"></a><div class="linenumber">3619</div><div style="width:6em;display:inline-block"></div>newPeerConn&nbsp;=&nbsp;{
<a name="line3620"></a><div class="linenumber">3620</div><div style="width:8em;display:inline-block"></div>pc:&nbsp;pc,
<a name="line3621"></a><div class="linenumber">3621</div><div style="width:8em;display:inline-block"></div>candidatesToSend:&nbsp;[],
<a name="line3622"></a><div class="linenumber">3622</div><div style="width:8em;display:inline-block"></div>startedAV:&nbsp;false,
<a name="line3623"></a><div class="linenumber">3623</div><div style="width:8em;display:inline-block"></div>connectionAccepted:&nbsp;false,
<a name="line3624"></a><div class="linenumber">3624</div><div style="width:8em;display:inline-block"></div>isInitiator:&nbsp;isInitiator,
<a name="line3625"></a><div class="linenumber">3625</div><div style="width:8em;display:inline-block"></div>remoteStreamIdToName:&nbsp;{},
<a name="line3626"></a><div class="linenumber">3626</div><div style="width:8em;display:inline-block"></div>streamsAddedAcks:&nbsp;{},
<a name="line3627"></a><div class="linenumber">3627</div><div style="width:8em;display:inline-block"></div>liveRemoteStreams:&nbsp;{}
<a name="line3628"></a><div class="linenumber">3628</div><div style="width:6em;display:inline-block"></div>};
<a name="line3629"></a><div class="linenumber">3629</div>
<a name="line3630"></a><div class="linenumber">3630</div><div style="width:6em;display:inline-block"></div>pc.onicecandidate&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3631"></a><div class="linenumber">3631</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[otherUser]&nbsp;&amp;&amp;&nbsp;peerConns[otherUser].cancelled)&nbsp;{
<a name="line3632"></a><div class="linenumber">3632</div><div style="width:10em;display:inline-block"></div>return;
<a name="line3633"></a><div class="linenumber">3633</div><div style="width:8em;display:inline-block"></div>}
<a name="line3634"></a><div class="linenumber">3634</div><div style="width:8em;display:inline-block"></div>var&nbsp;candidateData;
<a name="line3635"></a><div class="linenumber">3635</div><div style="width:8em;display:inline-block"></div>if&nbsp;(event.candidate&nbsp;&amp;&amp;&nbsp;peerConns[otherUser])&nbsp;{
<a name="line3636"></a><div class="linenumber">3636</div><div style="width:10em;display:inline-block"></div>candidateData&nbsp;=&nbsp;{
<a name="line3637"></a><div class="linenumber">3637</div><div style="width:12em;display:inline-block"></div>type:&nbsp;'candidate',
<a name="line3638"></a><div class="linenumber">3638</div><div style="width:12em;display:inline-block"></div>label:&nbsp;event.candidate.sdpMLineIndex,
<a name="line3639"></a><div class="linenumber">3639</div><div style="width:12em;display:inline-block"></div>id:&nbsp;event.candidate.sdpMid,
<a name="line3640"></a><div class="linenumber">3640</div><div style="width:12em;display:inline-block"></div>candidate:&nbsp;event.candidate.candidate
<a name="line3641"></a><div class="linenumber">3641</div><div style="width:10em;display:inline-block"></div>};
<a name="line3642"></a><div class="linenumber">3642</div>
<a name="line3643"></a><div class="linenumber">3643</div><div style="width:10em;display:inline-block"></div>if&nbsp;(iceCandidateFilter&nbsp;)&nbsp;{
<a name="line3644"></a><div class="linenumber">3644</div><div style="width:11em;display:inline-block"></div>candidateData&nbsp;=&nbsp;iceCandidateFilter(candidateData,&nbsp;false);
<a name="line3645"></a><div class="linenumber">3645</div><div style="width:11em;display:inline-block"></div>if(&nbsp;!candidateData&nbsp;)&nbsp;{
<a name="line3646"></a><div class="linenumber">3646</div><div style="width:13em;display:inline-block"></div>return;
<a name="line3647"></a><div class="linenumber">3647</div><div style="width:11em;display:inline-block"></div>}
<a name="line3648"></a><div class="linenumber">3648</div><div style="width:10em;display:inline-block"></div>}
<a name="line3649"></a><div class="linenumber">3649</div><div style="width:10em;display:inline-block"></div>//
<a name="line3650"></a><div class="linenumber">3650</div><div style="width:10em;display:inline-block"></div>//&nbsp;some&nbsp;candidates&nbsp;include&nbsp;ip&nbsp;addresses&nbsp;of&nbsp;turn&nbsp;servers.&nbsp;we'll&nbsp;want&nbsp;those
<a name="line3651"></a><div class="linenumber">3651</div><div style="width:10em;display:inline-block"></div>//&nbsp;later&nbsp;so&nbsp;we&nbsp;can&nbsp;see&nbsp;if&nbsp;our&nbsp;actual&nbsp;connection&nbsp;uses&nbsp;a&nbsp;turn&nbsp;server.
<a name="line3652"></a><div class="linenumber">3652</div><div style="width:10em;display:inline-block"></div>//&nbsp;The&nbsp;keyword&nbsp;"relay"&nbsp;in&nbsp;the&nbsp;candidate&nbsp;identifies&nbsp;it&nbsp;as&nbsp;referencing&nbsp;a
<a name="line3653"></a><div class="linenumber">3653</div><div style="width:10em;display:inline-block"></div>//&nbsp;turn&nbsp;server.&nbsp;The&nbsp;\d&nbsp;symbol&nbsp;in&nbsp;the&nbsp;regular&nbsp;expression&nbsp;matches&nbsp;a&nbsp;number.
<a name="line3654"></a><div class="linenumber">3654</div><div style="width:10em;display:inline-block"></div>//
<a name="line3655"></a><div class="linenumber">3655</div><div style="width:10em;display:inline-block"></div>processCandicate(event.candidate.candidate);
<a name="line3656"></a><div class="linenumber">3656</div>
<a name="line3657"></a><div class="linenumber">3657</div><div style="width:10em;display:inline-block"></div>if&nbsp;(peerConns[otherUser].connectionAccepted)&nbsp;{
<a name="line3658"></a><div class="linenumber">3658</div><div style="width:12em;display:inline-block"></div>sendSignalling(otherUser,&nbsp;"candidate",&nbsp;candidateData,&nbsp;null,&nbsp;function()&nbsp;{
<a name="line3659"></a><div class="linenumber">3659</div><div style="width:14em;display:inline-block"></div>failureCB(self.errCodes.PEER_GONE,&nbsp;"Candidate&nbsp;disappeared");
<a name="line3660"></a><div class="linenumber">3660</div><div style="width:12em;display:inline-block"></div>});
<a name="line3661"></a><div class="linenumber">3661</div><div style="width:10em;display:inline-block"></div>}
<a name="line3662"></a><div class="linenumber">3662</div><div style="width:10em;display:inline-block"></div>else&nbsp;{
<a name="line3663"></a><div class="linenumber">3663</div><div style="width:12em;display:inline-block"></div>peerConns[otherUser].candidatesToSend.push(candidateData);
<a name="line3664"></a><div class="linenumber">3664</div><div style="width:10em;display:inline-block"></div>}
<a name="line3665"></a><div class="linenumber">3665</div><div style="width:8em;display:inline-block"></div>}
<a name="line3666"></a><div class="linenumber">3666</div><div style="width:6em;display:inline-block"></div>};
<a name="line3667"></a><div class="linenumber">3667</div>
<a name="line3668"></a><div class="linenumber">3668</div><div style="width:6em;display:inline-block"></div>pc.ontrack&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3669"></a><div class="linenumber">3669</div><div style="width:8em;display:inline-block"></div>logDebug("empty&nbsp;ontrack&nbsp;method&nbsp;invoked,&nbsp;which&nbsp;is&nbsp;expected");
<a name="line3670"></a><div class="linenumber">3670</div><div style="width:8em;display:inline-block"></div>processAddedTrack(otherUser,&nbsp;event.streams);
<a name="line3671"></a><div class="linenumber">3671</div><div style="width:6em;display:inline-block"></div>};
<a name="line3672"></a><div class="linenumber">3672</div>
<a name="line3673"></a><div class="linenumber">3673</div><div style="width:6em;display:inline-block"></div>pc.onaddstream&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3674"></a><div class="linenumber">3674</div><div style="width:8em;display:inline-block"></div>logDebug("empty&nbsp;onaddstream&nbsp;method&nbsp;invoked,&nbsp;which&nbsp;is&nbsp;expected");
<a name="line3675"></a><div class="linenumber">3675</div><div style="width:8em;display:inline-block"></div>processAddedStream(otherUser,&nbsp;event.stream);
<a name="line3676"></a><div class="linenumber">3676</div><div style="width:6em;display:inline-block"></div>};
<a name="line3677"></a><div class="linenumber">3677</div>
<a name="line3678"></a><div class="linenumber">3678</div><div style="width:6em;display:inline-block"></div>pc.onremovestream&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3679"></a><div class="linenumber">3679</div><div style="width:8em;display:inline-block"></div>logDebug("saw&nbsp;remove&nbsp;on&nbsp;remote&nbsp;media&nbsp;stream");
<a name="line3680"></a><div class="linenumber">3680</div><div style="width:8em;display:inline-block"></div>onRemoveStreamHelper(otherUser,&nbsp;event.stream);
<a name="line3681"></a><div class="linenumber">3681</div><div style="width:6em;display:inline-block"></div>};
<a name="line3682"></a><div class="linenumber">3682</div>
<a name="line3683"></a><div class="linenumber">3683</div><div style="width:6em;display:inline-block"></div>//&nbsp;Register&nbsp;PeerConn
<a name="line3684"></a><div class="linenumber">3684</div><div style="width:6em;display:inline-block"></div>peerConns[otherUser]&nbsp;=&nbsp;newPeerConn;
<a name="line3685"></a><div class="linenumber">3685</div>
<a name="line3686"></a><div class="linenumber">3686</div><div style="width:4em;display:inline-block"></div>}&nbsp;catch&nbsp;(error)&nbsp;{
<a name="line3687"></a><div class="linenumber">3687</div><div style="width:6em;display:inline-block"></div>logDebug('buildPeerConnection&nbsp;error',&nbsp;error);
<a name="line3688"></a><div class="linenumber">3688</div><div style="width:6em;display:inline-block"></div>failureCB(self.errCodes.SYSTEM_ERR,&nbsp;error.message);
<a name="line3689"></a><div class="linenumber">3689</div><div style="width:6em;display:inline-block"></div>return&nbsp;null;
<a name="line3690"></a><div class="linenumber">3690</div><div style="width:4em;display:inline-block"></div>}
<a name="line3691"></a><div class="linenumber">3691</div>
<a name="line3692"></a><div class="linenumber">3692</div><div style="width:4em;display:inline-block"></div>var&nbsp;i,&nbsp;stream;
<a name="line3693"></a><div class="linenumber">3693</div><div style="width:4em;display:inline-block"></div>if&nbsp;(streamNames)&nbsp;{
<a name="line3694"></a><div class="linenumber">3694</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;streamNames.length;&nbsp;i++)&nbsp;{
<a name="line3695"></a><div class="linenumber">3695</div><div style="width:8em;display:inline-block"></div>stream&nbsp;=&nbsp;getLocalMediaStreamByName(streamNames[i]);
<a name="line3696"></a><div class="linenumber">3696</div><div style="width:8em;display:inline-block"></div>if&nbsp;(stream)&nbsp;{
<a name="line3697"></a><div class="linenumber">3697</div><div style="width:10em;display:inline-block"></div>pc.addStream(stream);
<a name="line3698"></a><div class="linenumber">3698</div><div style="width:8em;display:inline-block"></div>}
<a name="line3699"></a><div class="linenumber">3699</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line3700"></a><div class="linenumber">3700</div><div style="width:10em;display:inline-block"></div>logDebug("Developer&nbsp;error,&nbsp;attempt&nbsp;to&nbsp;access&nbsp;unknown&nbsp;local&nbsp;media&nbsp;stream&nbsp;"&nbsp;+&nbsp;streamNames[i]);
<a name="line3701"></a><div class="linenumber">3701</div><div style="width:8em;display:inline-block"></div>}
<a name="line3702"></a><div class="linenumber">3702</div><div style="width:6em;display:inline-block"></div>}
<a name="line3703"></a><div class="linenumber">3703</div><div style="width:4em;display:inline-block"></div>}
<a name="line3704"></a><div class="linenumber">3704</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(autoInitUserMedia&nbsp;&amp;&amp;&nbsp;(self.videoEnabled&nbsp;||&nbsp;self.audioEnabled))&nbsp;{
<a name="line3705"></a><div class="linenumber">3705</div><div style="width:6em;display:inline-block"></div>stream&nbsp;=&nbsp;self.getLocalStream();
<a name="line3706"></a><div class="linenumber">3706</div><div style="width:6em;display:inline-block"></div>pc.addStream(stream);
<a name="line3707"></a><div class="linenumber">3707</div><div style="width:4em;display:inline-block"></div>}
<a name="line3708"></a><div class="linenumber">3708</div>
<a name="line3709"></a><div class="linenumber">3709</div><div style="width:4em;display:inline-block"></div>//
<a name="line3710"></a><div class="linenumber">3710</div><div style="width:4em;display:inline-block"></div>//&nbsp;This&nbsp;function&nbsp;handles&nbsp;data&nbsp;channel&nbsp;message&nbsp;events.
<a name="line3711"></a><div class="linenumber">3711</div><div style="width:4em;display:inline-block"></div>//
<a name="line3712"></a><div class="linenumber">3712</div><div style="width:4em;display:inline-block"></div>var&nbsp;pendingTransfer&nbsp;=&nbsp;{};
<a name="line3713"></a><div class="linenumber">3713</div><div style="width:4em;display:inline-block"></div>function&nbsp;dataChannelMessageHandler(event)&nbsp;{
<a name="line3714"></a><div class="linenumber">3714</div><div style="width:6em;display:inline-block"></div>logDebug("saw&nbsp;dataChannel.onmessage&nbsp;event:&nbsp;",&nbsp;event.data);
<a name="line3715"></a><div class="linenumber">3715</div>
<a name="line3716"></a><div class="linenumber">3716</div><div style="width:6em;display:inline-block"></div>if&nbsp;(event.data&nbsp;===&nbsp;"dataChannelPrimed")&nbsp;{
<a name="line3717"></a><div class="linenumber">3717</div><div style="width:8em;display:inline-block"></div>self.sendDataWS(otherUser,&nbsp;"dataChannelPrimed",&nbsp;"");
<a name="line3718"></a><div class="linenumber">3718</div><div style="width:6em;display:inline-block"></div>}
<a name="line3719"></a><div class="linenumber">3719</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line3720"></a><div class="linenumber">3720</div><div style="width:8em;display:inline-block"></div>//
<a name="line3721"></a><div class="linenumber">3721</div><div style="width:8em;display:inline-block"></div>//&nbsp;Chrome&nbsp;and&nbsp;Firefox&nbsp;Interop&nbsp;is&nbsp;passing&nbsp;a&nbsp;event&nbsp;with&nbsp;a&nbsp;strange&nbsp;data="",&nbsp;perhaps
<a name="line3722"></a><div class="linenumber">3722</div><div style="width:8em;display:inline-block"></div>//&nbsp;as&nbsp;it's&nbsp;own&nbsp;form&nbsp;of&nbsp;priming&nbsp;message.&nbsp;Comparing&nbsp;the&nbsp;data&nbsp;against&nbsp;""&nbsp;doesn't
<a name="line3723"></a><div class="linenumber">3723</div><div style="width:8em;display:inline-block"></div>//&nbsp;work,&nbsp;so&nbsp;I'm&nbsp;going&nbsp;with&nbsp;parsing&nbsp;and&nbsp;trapping&nbsp;the&nbsp;parse&nbsp;error.
<a name="line3724"></a><div class="linenumber">3724</div><div style="width:8em;display:inline-block"></div>//
<a name="line3725"></a><div class="linenumber">3725</div><div style="width:8em;display:inline-block"></div>var&nbsp;msg;
<a name="line3726"></a><div class="linenumber">3726</div>
<a name="line3727"></a><div class="linenumber">3727</div><div style="width:8em;display:inline-block"></div>try&nbsp;{
<a name="line3728"></a><div class="linenumber">3728</div><div style="width:10em;display:inline-block"></div>msg&nbsp;=&nbsp;JSON.parse(event.data);
<a name="line3729"></a><div class="linenumber">3729</div><div style="width:8em;display:inline-block"></div>}&nbsp;catch&nbsp;(err)&nbsp;{
<a name="line3730"></a><div class="linenumber">3730</div><div style="width:10em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;unable&nbsp;to&nbsp;parse&nbsp;event&nbsp;data');
<a name="line3731"></a><div class="linenumber">3731</div><div style="width:8em;display:inline-block"></div>}
<a name="line3732"></a><div class="linenumber">3732</div>
<a name="line3733"></a><div class="linenumber">3733</div><div style="width:8em;display:inline-block"></div>if&nbsp;(msg)&nbsp;{
<a name="line3734"></a><div class="linenumber">3734</div><div style="width:10em;display:inline-block"></div>if&nbsp;(msg.transfer&nbsp;&amp;&amp;&nbsp;msg.transferId)&nbsp;{
<a name="line3735"></a><div class="linenumber">3735</div><div style="width:12em;display:inline-block"></div>if&nbsp;(msg.transfer&nbsp;===&nbsp;'start')&nbsp;{
<a name="line3736"></a><div class="linenumber">3736</div><div style="width:14em;display:inline-block"></div>logDebug('start&nbsp;transfer&nbsp;#'&nbsp;+&nbsp;msg.transferId);
<a name="line3737"></a><div class="linenumber">3737</div>
<a name="line3738"></a><div class="linenumber">3738</div><div style="width:14em;display:inline-block"></div>var&nbsp;parts&nbsp;=&nbsp;parseInt(msg.parts);
<a name="line3739"></a><div class="linenumber">3739</div><div style="width:14em;display:inline-block"></div>pendingTransfer&nbsp;=&nbsp;{
<a name="line3740"></a><div class="linenumber">3740</div><div style="width:16em;display:inline-block"></div>chunks:&nbsp;[],
<a name="line3741"></a><div class="linenumber">3741</div><div style="width:16em;display:inline-block"></div>parts:&nbsp;parts,
<a name="line3742"></a><div class="linenumber">3742</div><div style="width:16em;display:inline-block"></div>transferId:&nbsp;msg.transferId
<a name="line3743"></a><div class="linenumber">3743</div><div style="width:14em;display:inline-block"></div>};
<a name="line3744"></a><div class="linenumber">3744</div>
<a name="line3745"></a><div class="linenumber">3745</div><div style="width:12em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(msg.transfer&nbsp;===&nbsp;'chunk')&nbsp;{
<a name="line3746"></a><div class="linenumber">3746</div><div style="width:14em;display:inline-block"></div>logDebug('got&nbsp;chunk&nbsp;for&nbsp;transfer&nbsp;#'&nbsp;+&nbsp;msg.transferId);
<a name="line3747"></a><div class="linenumber">3747</div>
<a name="line3748"></a><div class="linenumber">3748</div><div style="width:14em;display:inline-block"></div>//&nbsp;check&nbsp;data&nbsp;is&nbsp;valid
<a name="line3749"></a><div class="linenumber">3749</div><div style="width:14em;display:inline-block"></div>if&nbsp;(!(typeof&nbsp;msg.data&nbsp;===&nbsp;'string'&nbsp;&amp;&amp;&nbsp;msg.data.length&nbsp;&lt;=&nbsp;self.maxP2PMessageLength))&nbsp;{
<a name="line3750"></a><div class="linenumber">3750</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;invalid&nbsp;data');
<a name="line3751"></a><div class="linenumber">3751</div>
<a name="line3752"></a><div class="linenumber">3752</div><div style="width:16em;display:inline-block"></div>//&nbsp;check&nbsp;there's&nbsp;a&nbsp;pending&nbsp;transfer
<a name="line3753"></a><div class="linenumber">3753</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(!pendingTransfer)&nbsp;{
<a name="line3754"></a><div class="linenumber">3754</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;unexpected&nbsp;chunk');
<a name="line3755"></a><div class="linenumber">3755</div>
<a name="line3756"></a><div class="linenumber">3756</div><div style="width:14em;display:inline-block"></div>//&nbsp;check&nbsp;that&nbsp;transferId&nbsp;is&nbsp;valid
<a name="line3757"></a><div class="linenumber">3757</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(msg.transferId&nbsp;!==&nbsp;pendingTransfer.transferId)&nbsp;{
<a name="line3758"></a><div class="linenumber">3758</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;invalid&nbsp;transfer&nbsp;id');
<a name="line3759"></a><div class="linenumber">3759</div>
<a name="line3760"></a><div class="linenumber">3760</div><div style="width:14em;display:inline-block"></div>//&nbsp;check&nbsp;that&nbsp;the&nbsp;max&nbsp;length&nbsp;of&nbsp;transfer&nbsp;is&nbsp;not&nbsp;reached
<a name="line3761"></a><div class="linenumber">3761</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(pendingTransfer.chunks.length&nbsp;+&nbsp;1&nbsp;&gt;&nbsp;pendingTransfer.parts)&nbsp;{
<a name="line3762"></a><div class="linenumber">3762</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;received&nbsp;too&nbsp;many&nbsp;chunks');
<a name="line3763"></a><div class="linenumber">3763</div>
<a name="line3764"></a><div class="linenumber">3764</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line3765"></a><div class="linenumber">3765</div><div style="width:16em;display:inline-block"></div>pendingTransfer.chunks.push(msg.data);
<a name="line3766"></a><div class="linenumber">3766</div><div style="width:14em;display:inline-block"></div>}
<a name="line3767"></a><div class="linenumber">3767</div>
<a name="line3768"></a><div class="linenumber">3768</div><div style="width:12em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(msg.transfer&nbsp;===&nbsp;'end')&nbsp;{
<a name="line3769"></a><div class="linenumber">3769</div><div style="width:14em;display:inline-block"></div>logDebug('end&nbsp;of&nbsp;transfer&nbsp;#'&nbsp;+&nbsp;msg.transferId);
<a name="line3770"></a><div class="linenumber">3770</div>
<a name="line3771"></a><div class="linenumber">3771</div><div style="width:14em;display:inline-block"></div>//&nbsp;check&nbsp;there's&nbsp;a&nbsp;pending&nbsp;transfer
<a name="line3772"></a><div class="linenumber">3772</div><div style="width:14em;display:inline-block"></div>if&nbsp;(!pendingTransfer)&nbsp;{
<a name="line3773"></a><div class="linenumber">3773</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;unexpected&nbsp;end&nbsp;of&nbsp;transfer');
<a name="line3774"></a><div class="linenumber">3774</div>
<a name="line3775"></a><div class="linenumber">3775</div><div style="width:14em;display:inline-block"></div>//&nbsp;check&nbsp;that&nbsp;transferId&nbsp;is&nbsp;valid
<a name="line3776"></a><div class="linenumber">3776</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(msg.transferId&nbsp;!==&nbsp;pendingTransfer.transferId)&nbsp;{
<a name="line3777"></a><div class="linenumber">3777</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;invalid&nbsp;transfer&nbsp;id');
<a name="line3778"></a><div class="linenumber">3778</div>
<a name="line3779"></a><div class="linenumber">3779</div><div style="width:14em;display:inline-block"></div>//&nbsp;check&nbsp;that&nbsp;all&nbsp;the&nbsp;chunks&nbsp;were&nbsp;received
<a name="line3780"></a><div class="linenumber">3780</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(pendingTransfer.chunks.length&nbsp;!==&nbsp;pendingTransfer.parts)&nbsp;{
<a name="line3781"></a><div class="linenumber">3781</div><div style="width:16em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;received&nbsp;wrong&nbsp;number&nbsp;of&nbsp;chunks');
<a name="line3782"></a><div class="linenumber">3782</div>
<a name="line3783"></a><div class="linenumber">3783</div><div style="width:14em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line3784"></a><div class="linenumber">3784</div><div style="width:16em;display:inline-block"></div>var&nbsp;chunkedMsg;
<a name="line3785"></a><div class="linenumber">3785</div><div style="width:16em;display:inline-block"></div>try&nbsp;{
<a name="line3786"></a><div class="linenumber">3786</div><div style="width:18em;display:inline-block"></div>chunkedMsg&nbsp;=&nbsp;JSON.parse(pendingTransfer.chunks.join(''));
<a name="line3787"></a><div class="linenumber">3787</div><div style="width:16em;display:inline-block"></div>}&nbsp;catch&nbsp;(err)&nbsp;{
<a name="line3788"></a><div class="linenumber">3788</div><div style="width:18em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;unable&nbsp;to&nbsp;parse&nbsp;message');
<a name="line3789"></a><div class="linenumber">3789</div><div style="width:16em;display:inline-block"></div>}
<a name="line3790"></a><div class="linenumber">3790</div>
<a name="line3791"></a><div class="linenumber">3791</div><div style="width:16em;display:inline-block"></div>if&nbsp;(chunkedMsg)&nbsp;{
<a name="line3792"></a><div class="linenumber">3792</div><div style="width:18em;display:inline-block"></div>self.receivePeerDistribute(otherUser,&nbsp;chunkedMsg,&nbsp;null);
<a name="line3793"></a><div class="linenumber">3793</div><div style="width:16em;display:inline-block"></div>}
<a name="line3794"></a><div class="linenumber">3794</div><div style="width:14em;display:inline-block"></div>}
<a name="line3795"></a><div class="linenumber">3795</div><div style="width:14em;display:inline-block"></div>pendingTransfer&nbsp;=&nbsp;{&nbsp;&nbsp;};
<a name="line3796"></a><div class="linenumber">3796</div>
<a name="line3797"></a><div class="linenumber">3797</div><div style="width:12em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line3798"></a><div class="linenumber">3798</div><div style="width:14em;display:inline-block"></div>logDebug('Developer&nbsp;error,&nbsp;got&nbsp;an&nbsp;unknown&nbsp;transfer&nbsp;message'&nbsp;+&nbsp;msg.transfer);
<a name="line3799"></a><div class="linenumber">3799</div><div style="width:12em;display:inline-block"></div>}
<a name="line3800"></a><div class="linenumber">3800</div><div style="width:10em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line3801"></a><div class="linenumber">3801</div><div style="width:12em;display:inline-block"></div>self.receivePeerDistribute(otherUser,&nbsp;msg,&nbsp;null);
<a name="line3802"></a><div class="linenumber">3802</div><div style="width:10em;display:inline-block"></div>}
<a name="line3803"></a><div class="linenumber">3803</div><div style="width:8em;display:inline-block"></div>}
<a name="line3804"></a><div class="linenumber">3804</div><div style="width:6em;display:inline-block"></div>}
<a name="line3805"></a><div class="linenumber">3805</div><div style="width:4em;display:inline-block"></div>}
<a name="line3806"></a><div class="linenumber">3806</div>
<a name="line3807"></a><div class="linenumber">3807</div><div style="width:4em;display:inline-block"></div>function&nbsp;initOutGoingChannel(otherUser)&nbsp;{
<a name="line3808"></a><div class="linenumber">3808</div><div style="width:6em;display:inline-block"></div>logDebug("saw&nbsp;initOutgoingChannel&nbsp;call");
<a name="line3809"></a><div class="linenumber">3809</div>
<a name="line3810"></a><div class="linenumber">3810</div><div style="width:6em;display:inline-block"></div>var&nbsp;dataChannel&nbsp;=&nbsp;pc.createDataChannel(dataChannelName,&nbsp;self.getDatachannelConstraints());
<a name="line3811"></a><div class="linenumber">3811</div><div style="width:6em;display:inline-block"></div>peerConns[otherUser].dataChannelS&nbsp;=&nbsp;dataChannel;
<a name="line3812"></a><div class="linenumber">3812</div><div style="width:6em;display:inline-block"></div>peerConns[otherUser].dataChannelR&nbsp;=&nbsp;dataChannel;
<a name="line3813"></a><div class="linenumber">3813</div><div style="width:6em;display:inline-block"></div>dataChannel.onmessage&nbsp;=&nbsp;dataChannelMessageHandler;
<a name="line3814"></a><div class="linenumber">3814</div><div style="width:6em;display:inline-block"></div>dataChannel.onopen&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3815"></a><div class="linenumber">3815</div><div style="width:8em;display:inline-block"></div>logDebug("saw&nbsp;dataChannel.onopen&nbsp;event");
<a name="line3816"></a><div class="linenumber">3816</div>
<a name="line3817"></a><div class="linenumber">3817</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3818"></a><div class="linenumber">3818</div><div style="width:10em;display:inline-block"></div>dataChannel.send("dataChannelPrimed");
<a name="line3819"></a><div class="linenumber">3819</div><div style="width:8em;display:inline-block"></div>}
<a name="line3820"></a><div class="linenumber">3820</div><div style="width:6em;display:inline-block"></div>};
<a name="line3821"></a><div class="linenumber">3821</div><div style="width:6em;display:inline-block"></div>dataChannel.onclose&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3822"></a><div class="linenumber">3822</div><div style="width:8em;display:inline-block"></div>logDebug("saw&nbsp;dataChannelS.onclose&nbsp;event");
<a name="line3823"></a><div class="linenumber">3823</div>
<a name="line3824"></a><div class="linenumber">3824</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3825"></a><div class="linenumber">3825</div><div style="width:10em;display:inline-block"></div>peerConns[otherUser].dataChannelReady&nbsp;=&nbsp;false;
<a name="line3826"></a><div class="linenumber">3826</div><div style="width:10em;display:inline-block"></div>delete&nbsp;peerConns[otherUser].dataChannelS;
<a name="line3827"></a><div class="linenumber">3827</div><div style="width:8em;display:inline-block"></div>}
<a name="line3828"></a><div class="linenumber">3828</div><div style="width:8em;display:inline-block"></div>if&nbsp;(onDataChannelClose)&nbsp;{
<a name="line3829"></a><div class="linenumber">3829</div><div style="width:10em;display:inline-block"></div>onDataChannelClose(otherUser);
<a name="line3830"></a><div class="linenumber">3830</div><div style="width:8em;display:inline-block"></div>}
<a name="line3831"></a><div class="linenumber">3831</div>
<a name="line3832"></a><div class="linenumber">3832</div><div style="width:8em;display:inline-block"></div>updateConfigurationInfo();
<a name="line3833"></a><div class="linenumber">3833</div><div style="width:6em;display:inline-block"></div>};
<a name="line3834"></a><div class="linenumber">3834</div><div style="width:4em;display:inline-block"></div>}
<a name="line3835"></a><div class="linenumber">3835</div>
<a name="line3836"></a><div class="linenumber">3836</div><div style="width:4em;display:inline-block"></div>function&nbsp;initIncomingChannel(otherUser)&nbsp;{
<a name="line3837"></a><div class="linenumber">3837</div><div style="width:6em;display:inline-block"></div>logDebug("initializing&nbsp;incoming&nbsp;channel&nbsp;handler&nbsp;for&nbsp;"&nbsp;+&nbsp;otherUser);
<a name="line3838"></a><div class="linenumber">3838</div>
<a name="line3839"></a><div class="linenumber">3839</div><div style="width:6em;display:inline-block"></div>peerConns[otherUser].pc.ondatachannel&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3840"></a><div class="linenumber">3840</div>
<a name="line3841"></a><div class="linenumber">3841</div><div style="width:8em;display:inline-block"></div>logDebug("saw&nbsp;incoming&nbsp;data&nbsp;channel");
<a name="line3842"></a><div class="linenumber">3842</div>
<a name="line3843"></a><div class="linenumber">3843</div><div style="width:8em;display:inline-block"></div>var&nbsp;dataChannel&nbsp;=&nbsp;event.channel;
<a name="line3844"></a><div class="linenumber">3844</div><div style="width:8em;display:inline-block"></div>peerConns[otherUser].dataChannelR&nbsp;=&nbsp;dataChannel;
<a name="line3845"></a><div class="linenumber">3845</div><div style="width:8em;display:inline-block"></div>peerConns[otherUser].dataChannelS&nbsp;=&nbsp;dataChannel;
<a name="line3846"></a><div class="linenumber">3846</div><div style="width:8em;display:inline-block"></div>peerConns[otherUser].dataChannelReady&nbsp;=&nbsp;true;
<a name="line3847"></a><div class="linenumber">3847</div><div style="width:8em;display:inline-block"></div>dataChannel.onmessage&nbsp;=&nbsp;dataChannelMessageHandler;
<a name="line3848"></a><div class="linenumber">3848</div><div style="width:8em;display:inline-block"></div>dataChannel.onclose&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3849"></a><div class="linenumber">3849</div><div style="width:10em;display:inline-block"></div>logDebug("saw&nbsp;dataChannelR.onclose&nbsp;event");
<a name="line3850"></a><div class="linenumber">3850</div>
<a name="line3851"></a><div class="linenumber">3851</div><div style="width:10em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3852"></a><div class="linenumber">3852</div><div style="width:12em;display:inline-block"></div>peerConns[otherUser].dataChannelReady&nbsp;=&nbsp;false;
<a name="line3853"></a><div class="linenumber">3853</div><div style="width:12em;display:inline-block"></div>delete&nbsp;peerConns[otherUser].dataChannelR;
<a name="line3854"></a><div class="linenumber">3854</div><div style="width:10em;display:inline-block"></div>}
<a name="line3855"></a><div class="linenumber">3855</div><div style="width:10em;display:inline-block"></div>if&nbsp;(onDataChannelClose)&nbsp;{
<a name="line3856"></a><div class="linenumber">3856</div><div style="width:12em;display:inline-block"></div>onDataChannelClose(otherUser);
<a name="line3857"></a><div class="linenumber">3857</div><div style="width:10em;display:inline-block"></div>}
<a name="line3858"></a><div class="linenumber">3858</div>
<a name="line3859"></a><div class="linenumber">3859</div><div style="width:10em;display:inline-block"></div>updateConfigurationInfo();
<a name="line3860"></a><div class="linenumber">3860</div><div style="width:8em;display:inline-block"></div>};
<a name="line3861"></a><div class="linenumber">3861</div><div style="width:8em;display:inline-block"></div>dataChannel.onopen&nbsp;=&nbsp;function(event)&nbsp;{
<a name="line3862"></a><div class="linenumber">3862</div><div style="width:10em;display:inline-block"></div>logDebug("saw&nbsp;dataChannel.onopen&nbsp;event");
<a name="line3863"></a><div class="linenumber">3863</div>
<a name="line3864"></a><div class="linenumber">3864</div><div style="width:10em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3865"></a><div class="linenumber">3865</div><div style="width:12em;display:inline-block"></div>dataChannel.send("dataChannelPrimed");
<a name="line3866"></a><div class="linenumber">3866</div><div style="width:10em;display:inline-block"></div>}
<a name="line3867"></a><div class="linenumber">3867</div><div style="width:8em;display:inline-block"></div>};
<a name="line3868"></a><div class="linenumber">3868</div><div style="width:6em;display:inline-block"></div>};
<a name="line3869"></a><div class="linenumber">3869</div><div style="width:4em;display:inline-block"></div>}
<a name="line3870"></a><div class="linenumber">3870</div>
<a name="line3871"></a><div class="linenumber">3871</div><div style="width:4em;display:inline-block"></div>//
<a name="line3872"></a><div class="linenumber">3872</div><div style="width:4em;display:inline-block"></div>//&nbsp;&nbsp;added&nbsp;for&nbsp;interoperability
<a name="line3873"></a><div class="linenumber">3873</div><div style="width:4em;display:inline-block"></div>//
<a name="line3874"></a><div class="linenumber">3874</div><div style="width:4em;display:inline-block"></div>//&nbsp;TODO&nbsp;check&nbsp;if&nbsp;both&nbsp;sides&nbsp;have&nbsp;the&nbsp;same&nbsp;browser&nbsp;and&nbsp;versions
<a name="line3875"></a><div class="linenumber">3875</div><div style="width:4em;display:inline-block"></div>if&nbsp;(dataEnabled)&nbsp;{
<a name="line3876"></a><div class="linenumber">3876</div><div style="width:6em;display:inline-block"></div>self.setPeerListener(function()&nbsp;{
<a name="line3877"></a><div class="linenumber">3877</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line3878"></a><div class="linenumber">3878</div><div style="width:10em;display:inline-block"></div>peerConns[otherUser].dataChannelReady&nbsp;=&nbsp;true;
<a name="line3879"></a><div class="linenumber">3879</div><div style="width:10em;display:inline-block"></div>if&nbsp;(peerConns[otherUser].callSuccessCB)&nbsp;{
<a name="line3880"></a><div class="linenumber">3880</div><div style="width:12em;display:inline-block"></div>peerConns[otherUser].callSuccessCB(otherUser,&nbsp;"datachannel");
<a name="line3881"></a><div class="linenumber">3881</div><div style="width:10em;display:inline-block"></div>}
<a name="line3882"></a><div class="linenumber">3882</div><div style="width:10em;display:inline-block"></div>if&nbsp;(onDataChannelOpen)&nbsp;{
<a name="line3883"></a><div class="linenumber">3883</div><div style="width:12em;display:inline-block"></div>onDataChannelOpen(otherUser,&nbsp;true);
<a name="line3884"></a><div class="linenumber">3884</div><div style="width:10em;display:inline-block"></div>}
<a name="line3885"></a><div class="linenumber">3885</div><div style="width:10em;display:inline-block"></div>updateConfigurationInfo();
<a name="line3886"></a><div class="linenumber">3886</div><div style="width:8em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line3887"></a><div class="linenumber">3887</div><div style="width:10em;display:inline-block"></div>logDebug("failed&nbsp;to&nbsp;setup&nbsp;outgoing&nbsp;channel&nbsp;listener");
<a name="line3888"></a><div class="linenumber">3888</div><div style="width:8em;display:inline-block"></div>}
<a name="line3889"></a><div class="linenumber">3889</div><div style="width:6em;display:inline-block"></div>},&nbsp;"dataChannelPrimed",&nbsp;otherUser);
<a name="line3890"></a><div class="linenumber">3890</div>
<a name="line3891"></a><div class="linenumber">3891</div><div style="width:6em;display:inline-block"></div>if&nbsp;(isInitiator)&nbsp;{
<a name="line3892"></a><div class="linenumber">3892</div><div style="width:8em;display:inline-block"></div>try&nbsp;{
<a name="line3893"></a><div class="linenumber">3893</div>
<a name="line3894"></a><div class="linenumber">3894</div><div style="width:10em;display:inline-block"></div>initOutGoingChannel(otherUser);
<a name="line3895"></a><div class="linenumber">3895</div><div style="width:8em;display:inline-block"></div>}&nbsp;catch&nbsp;(channelErrorEvent)&nbsp;{
<a name="line3896"></a><div class="linenumber">3896</div><div style="width:10em;display:inline-block"></div>logDebug("failed&nbsp;to&nbsp;init&nbsp;outgoing&nbsp;channel");
<a name="line3897"></a><div class="linenumber">3897</div><div style="width:10em;display:inline-block"></div>failureCB(self.errCodes.SYSTEM_ERR,
<a name="line3898"></a><div class="linenumber">3898</div><div style="width:14em;display:inline-block"></div>self.formatError(channelErrorEvent));
<a name="line3899"></a><div class="linenumber">3899</div><div style="width:8em;display:inline-block"></div>}
<a name="line3900"></a><div class="linenumber">3900</div><div style="width:6em;display:inline-block"></div>}
<a name="line3901"></a><div class="linenumber">3901</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!isInitiator)&nbsp;{
<a name="line3902"></a><div class="linenumber">3902</div><div style="width:8em;display:inline-block"></div>initIncomingChannel(otherUser);
<a name="line3903"></a><div class="linenumber">3903</div><div style="width:6em;display:inline-block"></div>}
<a name="line3904"></a><div class="linenumber">3904</div><div style="width:4em;display:inline-block"></div>}
<a name="line3905"></a><div class="linenumber">3905</div>
<a name="line3906"></a><div class="linenumber">3906</div><div style="width:4em;display:inline-block"></div>pc.onconnection&nbsp;=&nbsp;function()&nbsp;{
<a name="line3907"></a><div class="linenumber">3907</div><div style="width:6em;display:inline-block"></div>logDebug("setup&nbsp;pc.onconnection&nbsp;");
<a name="line3908"></a><div class="linenumber">3908</div><div style="width:4em;display:inline-block"></div>};
<a name="line3909"></a><div class="linenumber">3909</div>
<a name="line3910"></a><div class="linenumber">3910</div><div style="width:4em;display:inline-block"></div>//
<a name="line3911"></a><div class="linenumber">3911</div><div style="width:4em;display:inline-block"></div>//&nbsp;Temporary&nbsp;support&nbsp;for&nbsp;responding&nbsp;to&nbsp;acknowledgements&nbsp;of&nbsp;about&nbsp;streams&nbsp;being&nbsp;added.
<a name="line3912"></a><div class="linenumber">3912</div><div style="width:4em;display:inline-block"></div>//
<a name="line3913"></a><div class="linenumber">3913</div><div style="width:4em;display:inline-block"></div>self.setPeerListener(function(easyrtcid,&nbsp;msgType,&nbsp;msgData,&nbsp;targeting){
<a name="line3914"></a><div class="linenumber">3914</div><div style="width:6em;display:inline-block"></div>if(&nbsp;newPeerConn.streamsAddedAcks[msgData.streamName])&nbsp;{
<a name="line3915"></a><div class="linenumber">3915</div><div style="width:8em;display:inline-block"></div>(newPeerConn.streamsAddedAcks[msgData.streamName])(easyrtcid,&nbsp;msgData.streamName);
<a name="line3916"></a><div class="linenumber">3916</div><div style="width:8em;display:inline-block"></div>delete&nbsp;newPeerConn.streamsAddedAcks[msgData.streamName];
<a name="line3917"></a><div class="linenumber">3917</div><div style="width:6em;display:inline-block"></div>}
<a name="line3918"></a><div class="linenumber">3918</div><div style="width:4em;display:inline-block"></div>},&nbsp;"easyrtc_streamReceived",&nbsp;otherUser);
<a name="line3919"></a><div class="linenumber">3919</div><div style="width:4em;display:inline-block"></div>return&nbsp;pc;
<a name="line3920"></a><div class="linenumber">3920</div><div style="width:2em;display:inline-block"></div>}
<a name="line3921"></a><div class="linenumber">3921</div>
<a name="line3922"></a><div class="linenumber">3922</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line3923"></a><div class="linenumber">3923</div><div style="width:2em;display:inline-block"></div>function&nbsp;doAnswerBody(caller,&nbsp;msgData,&nbsp;streamNames)&nbsp;{
<a name="line3924"></a><div class="linenumber">3924</div><div style="width:4em;display:inline-block"></div>var&nbsp;pc&nbsp;=&nbsp;buildPeerConnection(caller,&nbsp;false,&nbsp;function(message)&nbsp;{
<a name="line3925"></a><div class="linenumber">3925</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.SYSTEM_ERR,&nbsp;message);
<a name="line3926"></a><div class="linenumber">3926</div><div style="width:4em;display:inline-block"></div>},&nbsp;streamNames);
<a name="line3927"></a><div class="linenumber">3927</div><div style="width:4em;display:inline-block"></div>var&nbsp;newPeerConn&nbsp;=&nbsp;peerConns[caller];
<a name="line3928"></a><div class="linenumber">3928</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!pc)&nbsp;{
<a name="line3929"></a><div class="linenumber">3929</div><div style="width:6em;display:inline-block"></div>logDebug("buildPeerConnection&nbsp;failed.&nbsp;Call&nbsp;not&nbsp;answered");
<a name="line3930"></a><div class="linenumber">3930</div><div style="width:6em;display:inline-block"></div>return;
<a name="line3931"></a><div class="linenumber">3931</div><div style="width:4em;display:inline-block"></div>}
<a name="line3932"></a><div class="linenumber">3932</div><div style="width:4em;display:inline-block"></div>var&nbsp;setLocalAndSendMessage1&nbsp;=&nbsp;function(sessionDescription)&nbsp;{
<a name="line3933"></a><div class="linenumber">3933</div>
<a name="line3934"></a><div class="linenumber">3934</div><div style="width:6em;display:inline-block"></div>if&nbsp;(newPeerConn.cancelled)&nbsp;{
<a name="line3935"></a><div class="linenumber">3935</div><div style="width:8em;display:inline-block"></div>return;
<a name="line3936"></a><div class="linenumber">3936</div><div style="width:6em;display:inline-block"></div>}
<a name="line3937"></a><div class="linenumber">3937</div>
<a name="line3938"></a><div class="linenumber">3938</div><div style="width:6em;display:inline-block"></div>var&nbsp;sendAnswer&nbsp;=&nbsp;function()&nbsp;{
<a name="line3939"></a><div class="linenumber">3939</div><div style="width:8em;display:inline-block"></div>logDebug("sending&nbsp;answer");
<a name="line3940"></a><div class="linenumber">3940</div>
<a name="line3941"></a><div class="linenumber">3941</div><div style="width:8em;display:inline-block"></div>function&nbsp;onSignalSuccess()&nbsp;{
<a name="line3942"></a><div class="linenumber">3942</div><div style="width:10em;display:inline-block"></div>logDebug("sending&nbsp;success");
<a name="line3943"></a><div class="linenumber">3943</div><div style="width:8em;display:inline-block"></div>}
<a name="line3944"></a><div class="linenumber">3944</div>
<a name="line3945"></a><div class="linenumber">3945</div><div style="width:8em;display:inline-block"></div>function&nbsp;onSignalFailure(errorCode,&nbsp;errorText)&nbsp;{
<a name="line3946"></a><div class="linenumber">3946</div><div style="width:10em;display:inline-block"></div>logDebug("sending&nbsp;error");
<a name="line3947"></a><div class="linenumber">3947</div><div style="width:10em;display:inline-block"></div>delete&nbsp;peerConns[caller];
<a name="line3948"></a><div class="linenumber">3948</div><div style="width:10em;display:inline-block"></div>self.showError(errorCode,&nbsp;errorText);
<a name="line3949"></a><div class="linenumber">3949</div><div style="width:8em;display:inline-block"></div>}
<a name="line3950"></a><div class="linenumber">3950</div>
<a name="line3951"></a><div class="linenumber">3951</div><div style="width:8em;display:inline-block"></div>sendSignalling(caller,&nbsp;"answer",&nbsp;sessionDescription,&nbsp;onSignalSuccess,&nbsp;onSignalFailure);
<a name="line3952"></a><div class="linenumber">3952</div><div style="width:8em;display:inline-block"></div>peerConns[caller].connectionAccepted&nbsp;=&nbsp;true;
<a name="line3953"></a><div class="linenumber">3953</div><div style="width:8em;display:inline-block"></div>sendQueuedCandidates(caller,&nbsp;onSignalSuccess,&nbsp;onSignalFailure);
<a name="line3954"></a><div class="linenumber">3954</div>
<a name="line3955"></a><div class="linenumber">3955</div><div style="width:8em;display:inline-block"></div>if&nbsp;(pc.connectDataConnection)&nbsp;{
<a name="line3956"></a><div class="linenumber">3956</div><div style="width:10em;display:inline-block"></div>logDebug("calling&nbsp;connectDataConnection(5002,5001)");
<a name="line3957"></a><div class="linenumber">3957</div><div style="width:10em;display:inline-block"></div>pc.connectDataConnection(5002,&nbsp;5001);
<a name="line3958"></a><div class="linenumber">3958</div><div style="width:8em;display:inline-block"></div>}
<a name="line3959"></a><div class="linenumber">3959</div><div style="width:6em;display:inline-block"></div>};
<a name="line3960"></a><div class="linenumber">3960</div><div style="width:6em;display:inline-block"></div>if&nbsp;(sdpLocalFilter)&nbsp;{
<a name="line3961"></a><div class="linenumber">3961</div><div style="width:8em;display:inline-block"></div>sessionDescription.sdp&nbsp;=&nbsp;sdpLocalFilter(sessionDescription.sdp);
<a name="line3962"></a><div class="linenumber">3962</div><div style="width:6em;display:inline-block"></div>}
<a name="line3963"></a><div class="linenumber">3963</div><div style="width:6em;display:inline-block"></div>pc.setLocalDescription(sessionDescription,&nbsp;sendAnswer,&nbsp;function(message)&nbsp;{
<a name="line3964"></a><div class="linenumber">3964</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"setLocalDescription:&nbsp;"&nbsp;+&nbsp;message);
<a name="line3965"></a><div class="linenumber">3965</div><div style="width:6em;display:inline-block"></div>});
<a name="line3966"></a><div class="linenumber">3966</div><div style="width:4em;display:inline-block"></div>};
<a name="line3967"></a><div class="linenumber">3967</div><div style="width:4em;display:inline-block"></div>var&nbsp;sd&nbsp;=&nbsp;new&nbsp;RTCSessionDescription(msgData);
<a name="line3968"></a><div class="linenumber">3968</div>
<a name="line3969"></a><div class="linenumber">3969</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!sd)&nbsp;{
<a name="line3970"></a><div class="linenumber">3970</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Could&nbsp;not&nbsp;create&nbsp;the&nbsp;RTCSessionDescription";
<a name="line3971"></a><div class="linenumber">3971</div><div style="width:4em;display:inline-block"></div>}
<a name="line3972"></a><div class="linenumber">3972</div>
<a name="line3973"></a><div class="linenumber">3973</div><div style="width:4em;display:inline-block"></div>logDebug("sdp&nbsp;||&nbsp;&nbsp;"&nbsp;+&nbsp;JSON.stringify(sd));
<a name="line3974"></a><div class="linenumber">3974</div>
<a name="line3975"></a><div class="linenumber">3975</div><div style="width:4em;display:inline-block"></div>var&nbsp;invokeCreateAnswer&nbsp;=&nbsp;function()&nbsp;{
<a name="line3976"></a><div class="linenumber">3976</div><div style="width:6em;display:inline-block"></div>if&nbsp;(newPeerConn.cancelled)&nbsp;{
<a name="line3977"></a><div class="linenumber">3977</div><div style="width:8em;display:inline-block"></div>return;
<a name="line3978"></a><div class="linenumber">3978</div><div style="width:6em;display:inline-block"></div>}
<a name="line3979"></a><div class="linenumber">3979</div><div style="width:6em;display:inline-block"></div>pc.createAnswer(setLocalAndSendMessage1,
<a name="line3980"></a><div class="linenumber">3980</div><div style="width:8em;display:inline-block"></div>function(message)&nbsp;{
<a name="line3981"></a><div class="linenumber">3981</div><div style="width:10em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"create-answer:&nbsp;"&nbsp;+&nbsp;message);
<a name="line3982"></a><div class="linenumber">3982</div><div style="width:8em;display:inline-block"></div>},
<a name="line3983"></a><div class="linenumber">3983</div><div style="width:8em;display:inline-block"></div>receivedMediaConstraints);
<a name="line3984"></a><div class="linenumber">3984</div><div style="width:4em;display:inline-block"></div>};
<a name="line3985"></a><div class="linenumber">3985</div>
<a name="line3986"></a><div class="linenumber">3986</div><div style="width:4em;display:inline-block"></div>logDebug("about&nbsp;to&nbsp;call&nbsp;setRemoteDescription&nbsp;in&nbsp;doAnswer");
<a name="line3987"></a><div class="linenumber">3987</div>
<a name="line3988"></a><div class="linenumber">3988</div><div style="width:4em;display:inline-block"></div>try&nbsp;{
<a name="line3989"></a><div class="linenumber">3989</div>
<a name="line3990"></a><div class="linenumber">3990</div><div style="width:6em;display:inline-block"></div>if&nbsp;(sdpRemoteFilter)&nbsp;{
<a name="line3991"></a><div class="linenumber">3991</div><div style="width:8em;display:inline-block"></div>sd.sdp&nbsp;=&nbsp;sdpRemoteFilter(sd.sdp);
<a name="line3992"></a><div class="linenumber">3992</div><div style="width:6em;display:inline-block"></div>}
<a name="line3993"></a><div class="linenumber">3993</div><div style="width:6em;display:inline-block"></div>pc.setRemoteDescription(sd,&nbsp;invokeCreateAnswer,&nbsp;function(message)&nbsp;{
<a name="line3994"></a><div class="linenumber">3994</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"set-remote-description:&nbsp;"&nbsp;+&nbsp;message);
<a name="line3995"></a><div class="linenumber">3995</div><div style="width:6em;display:inline-block"></div>});
<a name="line3996"></a><div class="linenumber">3996</div><div style="width:4em;display:inline-block"></div>}&nbsp;catch&nbsp;(srdError)&nbsp;{
<a name="line3997"></a><div class="linenumber">3997</div><div style="width:6em;display:inline-block"></div>logDebug("set&nbsp;remote&nbsp;description&nbsp;failed");
<a name="line3998"></a><div class="linenumber">3998</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"setRemoteDescription&nbsp;failed:&nbsp;"&nbsp;+&nbsp;srdError.message);
<a name="line3999"></a><div class="linenumber">3999</div><div style="width:4em;display:inline-block"></div>}
<a name="line4000"></a><div class="linenumber">4000</div><div style="width:2em;display:inline-block"></div>}
<a name="line4001"></a><div class="linenumber">4001</div>
<a name="line4002"></a><div class="linenumber">4002</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4003"></a><div class="linenumber">4003</div><div style="width:2em;display:inline-block"></div>function&nbsp;doAnswer(caller,&nbsp;msgData,&nbsp;streamNames)&nbsp;{
<a name="line4004"></a><div class="linenumber">4004</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamNames&nbsp;&amp;&amp;&nbsp;autoInitUserMedia)&nbsp;{
<a name="line4005"></a><div class="linenumber">4005</div><div style="width:6em;display:inline-block"></div>var&nbsp;localStream&nbsp;=&nbsp;self.getLocalStream();
<a name="line4006"></a><div class="linenumber">4006</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!localStream&nbsp;&amp;&amp;&nbsp;(self.videoEnabled&nbsp;||&nbsp;self.audioEnabled))&nbsp;{
<a name="line4007"></a><div class="linenumber">4007</div><div style="width:8em;display:inline-block"></div>self.initMediaSource(
<a name="line4008"></a><div class="linenumber">4008</div><div style="width:12em;display:inline-block"></div>function()&nbsp;{
<a name="line4009"></a><div class="linenumber">4009</div><div style="width:14em;display:inline-block"></div>doAnswer(caller,&nbsp;msgData);
<a name="line4010"></a><div class="linenumber">4010</div><div style="width:12em;display:inline-block"></div>},
<a name="line4011"></a><div class="linenumber">4011</div><div style="width:12em;display:inline-block"></div>function(errorCode,&nbsp;error)&nbsp;{
<a name="line4012"></a><div class="linenumber">4012</div><div style="width:14em;display:inline-block"></div>self.showError(self.errCodes.MEDIA_ERR,&nbsp;self.format(self.getConstantString("localMediaError")));
<a name="line4013"></a><div class="linenumber">4013</div><div style="width:12em;display:inline-block"></div>});
<a name="line4014"></a><div class="linenumber">4014</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4015"></a><div class="linenumber">4015</div><div style="width:6em;display:inline-block"></div>}
<a name="line4016"></a><div class="linenumber">4016</div><div style="width:4em;display:inline-block"></div>}
<a name="line4017"></a><div class="linenumber">4017</div><div style="width:4em;display:inline-block"></div>if&nbsp;(use_fresh_ice_each_peer)&nbsp;{
<a name="line4018"></a><div class="linenumber">4018</div><div style="width:6em;display:inline-block"></div>self.getFreshIceConfig(function(succeeded)&nbsp;{
<a name="line4019"></a><div class="linenumber">4019</div><div style="width:8em;display:inline-block"></div>if&nbsp;(succeeded)&nbsp;{
<a name="line4020"></a><div class="linenumber">4020</div><div style="width:10em;display:inline-block"></div>doAnswerBody(caller,&nbsp;msgData,&nbsp;streamNames);
<a name="line4021"></a><div class="linenumber">4021</div><div style="width:8em;display:inline-block"></div>}
<a name="line4022"></a><div class="linenumber">4022</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line4023"></a><div class="linenumber">4023</div><div style="width:10em;display:inline-block"></div>self.showError(self.errCodes.CALL_ERR,&nbsp;"Failed&nbsp;to&nbsp;get&nbsp;fresh&nbsp;ice&nbsp;config");
<a name="line4024"></a><div class="linenumber">4024</div><div style="width:8em;display:inline-block"></div>}
<a name="line4025"></a><div class="linenumber">4025</div><div style="width:6em;display:inline-block"></div>});
<a name="line4026"></a><div class="linenumber">4026</div><div style="width:4em;display:inline-block"></div>}
<a name="line4027"></a><div class="linenumber">4027</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4028"></a><div class="linenumber">4028</div><div style="width:6em;display:inline-block"></div>doAnswerBody(caller,&nbsp;msgData,&nbsp;streamNames);
<a name="line4029"></a><div class="linenumber">4029</div><div style="width:4em;display:inline-block"></div>}
<a name="line4030"></a><div class="linenumber">4030</div><div style="width:2em;display:inline-block"></div>}
<a name="line4031"></a><div class="linenumber">4031</div>
<a name="line4032"></a><div class="linenumber">4032</div>
<a name="line4033"></a><div class="linenumber">4033</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4034"></a><div class="linenumber">4034</div><div style="width:2em;display:inline-block"></div>function&nbsp;callBody(otherUser,&nbsp;callSuccessCB,&nbsp;callFailureCB,&nbsp;wasAcceptedCB,&nbsp;streamNames)&nbsp;{
<a name="line4035"></a><div class="linenumber">4035</div><div style="width:4em;display:inline-block"></div>acceptancePending[otherUser]&nbsp;=&nbsp;true;
<a name="line4036"></a><div class="linenumber">4036</div><div style="width:4em;display:inline-block"></div>var&nbsp;pc&nbsp;=&nbsp;buildPeerConnection(otherUser,&nbsp;true,&nbsp;callFailureCB,&nbsp;streamNames);
<a name="line4037"></a><div class="linenumber">4037</div><div style="width:4em;display:inline-block"></div>var&nbsp;message;
<a name="line4038"></a><div class="linenumber">4038</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!pc)&nbsp;{
<a name="line4039"></a><div class="linenumber">4039</div><div style="width:6em;display:inline-block"></div>message&nbsp;=&nbsp;"buildPeerConnection&nbsp;failed,&nbsp;call&nbsp;not&nbsp;completed";
<a name="line4040"></a><div class="linenumber">4040</div><div style="width:6em;display:inline-block"></div>logDebug(message);
<a name="line4041"></a><div class="linenumber">4041</div><div style="width:6em;display:inline-block"></div>throw&nbsp;message;
<a name="line4042"></a><div class="linenumber">4042</div><div style="width:4em;display:inline-block"></div>}
<a name="line4043"></a><div class="linenumber">4043</div>
<a name="line4044"></a><div class="linenumber">4044</div><div style="width:4em;display:inline-block"></div>peerConns[otherUser].callSuccessCB&nbsp;=&nbsp;callSuccessCB;
<a name="line4045"></a><div class="linenumber">4045</div><div style="width:4em;display:inline-block"></div>peerConns[otherUser].callFailureCB&nbsp;=&nbsp;callFailureCB;
<a name="line4046"></a><div class="linenumber">4046</div><div style="width:4em;display:inline-block"></div>peerConns[otherUser].wasAcceptedCB&nbsp;=&nbsp;wasAcceptedCB;
<a name="line4047"></a><div class="linenumber">4047</div><div style="width:4em;display:inline-block"></div>var&nbsp;peerConnObj&nbsp;=&nbsp;peerConns[otherUser];
<a name="line4048"></a><div class="linenumber">4048</div><div style="width:4em;display:inline-block"></div>var&nbsp;setLocalAndSendMessage0&nbsp;=&nbsp;function(sessionDescription)&nbsp;{
<a name="line4049"></a><div class="linenumber">4049</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConnObj.cancelled)&nbsp;{
<a name="line4050"></a><div class="linenumber">4050</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4051"></a><div class="linenumber">4051</div><div style="width:6em;display:inline-block"></div>}
<a name="line4052"></a><div class="linenumber">4052</div><div style="width:6em;display:inline-block"></div>var&nbsp;sendOffer&nbsp;=&nbsp;function()&nbsp;{
<a name="line4053"></a><div class="linenumber">4053</div>
<a name="line4054"></a><div class="linenumber">4054</div><div style="width:8em;display:inline-block"></div>sendSignalling(otherUser,&nbsp;"offer",&nbsp;sessionDescription,&nbsp;null,&nbsp;callFailureCB);
<a name="line4055"></a><div class="linenumber">4055</div><div style="width:6em;display:inline-block"></div>};
<a name="line4056"></a><div class="linenumber">4056</div><div style="width:6em;display:inline-block"></div>if&nbsp;(sdpLocalFilter)&nbsp;{
<a name="line4057"></a><div class="linenumber">4057</div><div style="width:8em;display:inline-block"></div>sessionDescription.sdp&nbsp;=&nbsp;sdpLocalFilter(sessionDescription.sdp);
<a name="line4058"></a><div class="linenumber">4058</div><div style="width:6em;display:inline-block"></div>}
<a name="line4059"></a><div class="linenumber">4059</div><div style="width:6em;display:inline-block"></div>pc.setLocalDescription(sessionDescription,&nbsp;sendOffer,
<a name="line4060"></a><div class="linenumber">4060</div><div style="width:10em;display:inline-block"></div>function(errorText)&nbsp;{
<a name="line4061"></a><div class="linenumber">4061</div><div style="width:12em;display:inline-block"></div>callFailureCB(self.errCodes.CALL_ERR,&nbsp;errorText);
<a name="line4062"></a><div class="linenumber">4062</div><div style="width:10em;display:inline-block"></div>});
<a name="line4063"></a><div class="linenumber">4063</div><div style="width:4em;display:inline-block"></div>};
<a name="line4064"></a><div class="linenumber">4064</div><div style="width:4em;display:inline-block"></div>setTimeout(function()&nbsp;{
<a name="line4065"></a><div class="linenumber">4065</div><div style="width:6em;display:inline-block"></div>//
<a name="line4066"></a><div class="linenumber">4066</div><div style="width:6em;display:inline-block"></div>//&nbsp;if&nbsp;the&nbsp;call&nbsp;was&nbsp;cancelled,&nbsp;we&nbsp;don't&nbsp;want&nbsp;to&nbsp;continue&nbsp;getting&nbsp;the&nbsp;offer.
<a name="line4067"></a><div class="linenumber">4067</div><div style="width:6em;display:inline-block"></div>//&nbsp;we&nbsp;can&nbsp;tell&nbsp;the&nbsp;call&nbsp;was&nbsp;cancelled&nbsp;because&nbsp;there&nbsp;won't&nbsp;be&nbsp;a&nbsp;peerConn&nbsp;object
<a name="line4068"></a><div class="linenumber">4068</div><div style="width:6em;display:inline-block"></div>//&nbsp;for&nbsp;it.
<a name="line4069"></a><div class="linenumber">4069</div><div style="width:6em;display:inline-block"></div>//
<a name="line4070"></a><div class="linenumber">4070</div><div style="width:6em;display:inline-block"></div>if(&nbsp;!peerConns[otherUser])&nbsp;{
<a name="line4071"></a><div class="linenumber">4071</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4072"></a><div class="linenumber">4072</div><div style="width:6em;display:inline-block"></div>}
<a name="line4073"></a><div class="linenumber">4073</div><div style="width:6em;display:inline-block"></div>pc.createOffer(setLocalAndSendMessage0,&nbsp;function(errorObj)&nbsp;{
<a name="line4074"></a><div class="linenumber">4074</div><div style="width:8em;display:inline-block"></div>callFailureCB(self.errCodes.CALL_ERR,&nbsp;JSON.stringify(errorObj));
<a name="line4075"></a><div class="linenumber">4075</div><div style="width:6em;display:inline-block"></div>},
<a name="line4076"></a><div class="linenumber">4076</div><div style="width:10em;display:inline-block"></div>receivedMediaConstraints);
<a name="line4077"></a><div class="linenumber">4077</div><div style="width:4em;display:inline-block"></div>},&nbsp;100);
<a name="line4078"></a><div class="linenumber">4078</div><div style="width:2em;display:inline-block"></div>}
<a name="line4079"></a><div class="linenumber">4079</div>
<a name="line4080"></a><div class="linenumber">4080</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4081"></a><div class="linenumber">4081</div><div style="width:2em;display:inline-block"></div>*&nbsp;Initiates&nbsp;a&nbsp;call&nbsp;to&nbsp;another&nbsp;user.&nbsp;If&nbsp;it&nbsp;succeeds,&nbsp;the&nbsp;streamAcceptor&nbsp;callback&nbsp;will&nbsp;be&nbsp;called.
<a name="line4082"></a><div class="linenumber">4082</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;otherUser&nbsp;-&nbsp;the&nbsp;easyrtcid&nbsp;of&nbsp;the&nbsp;peer&nbsp;being&nbsp;called.
<a name="line4083"></a><div class="linenumber">4083</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callSuccessCB&nbsp;(otherCaller,&nbsp;mediaType)&nbsp;-&nbsp;is&nbsp;called&nbsp;when&nbsp;the&nbsp;datachannel&nbsp;is&nbsp;established&nbsp;or&nbsp;the&nbsp;MediaStream&nbsp;is&nbsp;established.&nbsp;mediaType&nbsp;will&nbsp;have&nbsp;a&nbsp;value&nbsp;of&nbsp;"audiovideo"&nbsp;or&nbsp;"datachannel"
<a name="line4084"></a><div class="linenumber">4084</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callFailureCB&nbsp;(errorCode,&nbsp;errMessage)&nbsp;-&nbsp;is&nbsp;called&nbsp;if&nbsp;there&nbsp;was&nbsp;a&nbsp;system&nbsp;error&nbsp;interfering&nbsp;with&nbsp;the&nbsp;call.
<a name="line4085"></a><div class="linenumber">4085</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;wasAcceptedCB&nbsp;(wasAccepted:boolean,otherUser:string)&nbsp;-&nbsp;is&nbsp;called&nbsp;when&nbsp;a&nbsp;call&nbsp;is&nbsp;accepted&nbsp;or&nbsp;rejected&nbsp;by&nbsp;another&nbsp;party.&nbsp;It&nbsp;can&nbsp;be&nbsp;left&nbsp;null.
<a name="line4086"></a><div class="linenumber">4086</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Array}&nbsp;streamNames&nbsp;-&nbsp;optional&nbsp;array&nbsp;of&nbsp;streamNames.
<a name="line4087"></a><div class="linenumber">4087</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line4088"></a><div class="linenumber">4088</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.call(&nbsp;otherEasyrtcid,
<a name="line4089"></a><div class="linenumber">4089</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(easyrtcid,&nbsp;mediaType){
<a name="line4090"></a><div class="linenumber">4090</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("Got&nbsp;mediaType&nbsp;"&nbsp;+&nbsp;mediaType&nbsp;+&nbsp;"&nbsp;from&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid));
<a name="line4091"></a><div class="linenumber">4091</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line4092"></a><div class="linenumber">4092</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorCode,&nbsp;errMessage){
<a name="line4093"></a><div class="linenumber">4093</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("call&nbsp;to&nbsp;&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(otherEasyrtcid)&nbsp;+&nbsp;"&nbsp;failed:"&nbsp;+&nbsp;errMessage);
<a name="line4094"></a><div class="linenumber">4094</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line4095"></a><div class="linenumber">4095</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(wasAccepted,&nbsp;easyrtcid){
<a name="line4096"></a><div class="linenumber">4096</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;wasAccepted&nbsp;){
<a name="line4097"></a><div class="linenumber">4097</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("call&nbsp;accepted&nbsp;by&nbsp;"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid));
<a name="line4098"></a><div class="linenumber">4098</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line4099"></a><div class="linenumber">4099</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else{
<a name="line4100"></a><div class="linenumber">4100</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("call&nbsp;rejected"&nbsp;+&nbsp;easyrtc.idToName(easyrtcid));
<a name="line4101"></a><div class="linenumber">4101</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line4102"></a><div class="linenumber">4102</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line4103"></a><div class="linenumber">4103</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4104"></a><div class="linenumber">4104</div><div style="width:2em;display:inline-block"></div>this.call&nbsp;=&nbsp;function(otherUser,&nbsp;callSuccessCB,&nbsp;callFailureCB,&nbsp;wasAcceptedCB,&nbsp;streamNames)&nbsp;{
<a name="line4105"></a><div class="linenumber">4105</div>
<a name="line4106"></a><div class="linenumber">4106</div><div style="width:4em;display:inline-block"></div>if&nbsp;(streamNames)&nbsp;{
<a name="line4107"></a><div class="linenumber">4107</div><div style="width:6em;display:inline-block"></div>if&nbsp;(typeof&nbsp;streamNames&nbsp;===&nbsp;"string")&nbsp;{&nbsp;//&nbsp;accept&nbsp;a&nbsp;string&nbsp;argument&nbsp;if&nbsp;passed.
<a name="line4108"></a><div class="linenumber">4108</div><div style="width:8em;display:inline-block"></div>streamNames&nbsp;=&nbsp;[streamNames];
<a name="line4109"></a><div class="linenumber">4109</div><div style="width:6em;display:inline-block"></div>}
<a name="line4110"></a><div class="linenumber">4110</div><div style="width:6em;display:inline-block"></div>else&nbsp;if&nbsp;(typeof&nbsp;streamNames.length&nbsp;===&nbsp;"undefined")&nbsp;{
<a name="line4111"></a><div class="linenumber">4111</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"easyrtc.call&nbsp;passed&nbsp;bad&nbsp;streamNames");
<a name="line4112"></a><div class="linenumber">4112</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4113"></a><div class="linenumber">4113</div><div style="width:6em;display:inline-block"></div>}
<a name="line4114"></a><div class="linenumber">4114</div><div style="width:4em;display:inline-block"></div>}
<a name="line4115"></a><div class="linenumber">4115</div>
<a name="line4116"></a><div class="linenumber">4116</div><div style="width:4em;display:inline-block"></div>logDebug("initiating&nbsp;peer&nbsp;to&nbsp;peer&nbsp;call&nbsp;to&nbsp;"&nbsp;+&nbsp;otherUser&nbsp;+
<a name="line4117"></a><div class="linenumber">4117</div><div style="width:10em;display:inline-block"></div>"&nbsp;audio="&nbsp;+&nbsp;self.audioEnabled&nbsp;+
<a name="line4118"></a><div class="linenumber">4118</div><div style="width:10em;display:inline-block"></div>"&nbsp;video="&nbsp;+&nbsp;self.videoEnabled&nbsp;+
<a name="line4119"></a><div class="linenumber">4119</div><div style="width:10em;display:inline-block"></div>"&nbsp;data="&nbsp;+&nbsp;dataEnabled);
<a name="line4120"></a><div class="linenumber">4120</div>
<a name="line4121"></a><div class="linenumber">4121</div>
<a name="line4122"></a><div class="linenumber">4122</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.supportsPeerConnections())&nbsp;{
<a name="line4123"></a><div class="linenumber">4123</div><div style="width:6em;display:inline-block"></div>callFailureCB(self.errCodes.CALL_ERR,&nbsp;self.getConstantString("noWebrtcSupport"));
<a name="line4124"></a><div class="linenumber">4124</div><div style="width:6em;display:inline-block"></div>return;
<a name="line4125"></a><div class="linenumber">4125</div><div style="width:4em;display:inline-block"></div>}
<a name="line4126"></a><div class="linenumber">4126</div>
<a name="line4127"></a><div class="linenumber">4127</div><div style="width:4em;display:inline-block"></div>var&nbsp;message;
<a name="line4128"></a><div class="linenumber">4128</div><div style="width:4em;display:inline-block"></div>//
<a name="line4129"></a><div class="linenumber">4129</div><div style="width:4em;display:inline-block"></div>//&nbsp;If&nbsp;we&nbsp;are&nbsp;sharing&nbsp;audio/video&nbsp;and&nbsp;we&nbsp;haven't&nbsp;allocated&nbsp;the&nbsp;local&nbsp;media&nbsp;stream&nbsp;yet,
<a name="line4130"></a><div class="linenumber">4130</div><div style="width:4em;display:inline-block"></div>//&nbsp;we'll&nbsp;do&nbsp;so,&nbsp;recalling&nbsp;our&nbsp;self&nbsp;on&nbsp;success.
<a name="line4131"></a><div class="linenumber">4131</div><div style="width:4em;display:inline-block"></div>//
<a name="line4132"></a><div class="linenumber">4132</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!streamNames&nbsp;&amp;&amp;&nbsp;autoInitUserMedia)&nbsp;{
<a name="line4133"></a><div class="linenumber">4133</div><div style="width:6em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;self.getLocalStream();
<a name="line4134"></a><div class="linenumber">4134</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!stream&nbsp;&amp;&amp;&nbsp;(self.audioEnabled&nbsp;||&nbsp;self.videoEnabled))&nbsp;{
<a name="line4135"></a><div class="linenumber">4135</div><div style="width:8em;display:inline-block"></div>self.initMediaSource(function()&nbsp;{
<a name="line4136"></a><div class="linenumber">4136</div><div style="width:10em;display:inline-block"></div>self.call(otherUser,&nbsp;callSuccessCB,&nbsp;callFailureCB,&nbsp;wasAcceptedCB);
<a name="line4137"></a><div class="linenumber">4137</div><div style="width:8em;display:inline-block"></div>},&nbsp;callFailureCB);
<a name="line4138"></a><div class="linenumber">4138</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4139"></a><div class="linenumber">4139</div><div style="width:6em;display:inline-block"></div>}
<a name="line4140"></a><div class="linenumber">4140</div><div style="width:4em;display:inline-block"></div>}
<a name="line4141"></a><div class="linenumber">4141</div>
<a name="line4142"></a><div class="linenumber">4142</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.webSocket)&nbsp;{
<a name="line4143"></a><div class="linenumber">4143</div><div style="width:6em;display:inline-block"></div>message&nbsp;=&nbsp;"Attempt&nbsp;to&nbsp;make&nbsp;a&nbsp;call&nbsp;prior&nbsp;to&nbsp;connecting&nbsp;to&nbsp;service";
<a name="line4144"></a><div class="linenumber">4144</div><div style="width:6em;display:inline-block"></div>logDebug(message);
<a name="line4145"></a><div class="linenumber">4145</div><div style="width:6em;display:inline-block"></div>throw&nbsp;message;
<a name="line4146"></a><div class="linenumber">4146</div><div style="width:4em;display:inline-block"></div>}
<a name="line4147"></a><div class="linenumber">4147</div>
<a name="line4148"></a><div class="linenumber">4148</div><div style="width:4em;display:inline-block"></div>//
<a name="line4149"></a><div class="linenumber">4149</div><div style="width:4em;display:inline-block"></div>//&nbsp;If&nbsp;B&nbsp;calls&nbsp;A,&nbsp;and&nbsp;then&nbsp;A&nbsp;calls&nbsp;B&nbsp;before&nbsp;accepting,&nbsp;then&nbsp;A&nbsp;should&nbsp;treat&nbsp;the&nbsp;attempt&nbsp;to
<a name="line4150"></a><div class="linenumber">4150</div><div style="width:4em;display:inline-block"></div>//&nbsp;call&nbsp;B&nbsp;as&nbsp;a&nbsp;positive&nbsp;offer&nbsp;to&nbsp;B's&nbsp;offer.
<a name="line4151"></a><div class="linenumber">4151</div><div style="width:4em;display:inline-block"></div>//
<a name="line4152"></a><div class="linenumber">4152</div><div style="width:4em;display:inline-block"></div>if&nbsp;(offersPending[otherUser])&nbsp;{
<a name="line4153"></a><div class="linenumber">4153</div><div style="width:6em;display:inline-block"></div>wasAcceptedCB(true,&nbsp;otherUser);
<a name="line4154"></a><div class="linenumber">4154</div><div style="width:6em;display:inline-block"></div>doAnswer(otherUser,&nbsp;offersPending[otherUser],&nbsp;streamNames);
<a name="line4155"></a><div class="linenumber">4155</div><div style="width:6em;display:inline-block"></div>delete&nbsp;offersPending[otherUser];
<a name="line4156"></a><div class="linenumber">4156</div><div style="width:6em;display:inline-block"></div>self.callCancelled(otherUser,&nbsp;false);
<a name="line4157"></a><div class="linenumber">4157</div><div style="width:6em;display:inline-block"></div>return;
<a name="line4158"></a><div class="linenumber">4158</div><div style="width:4em;display:inline-block"></div>}
<a name="line4159"></a><div class="linenumber">4159</div>
<a name="line4160"></a><div class="linenumber">4160</div><div style="width:4em;display:inline-block"></div>//&nbsp;do&nbsp;we&nbsp;already&nbsp;have&nbsp;a&nbsp;pending&nbsp;call?
<a name="line4161"></a><div class="linenumber">4161</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;acceptancePending[otherUser]&nbsp;!==&nbsp;'undefined')&nbsp;{
<a name="line4162"></a><div class="linenumber">4162</div><div style="width:6em;display:inline-block"></div>message&nbsp;=&nbsp;"Call&nbsp;already&nbsp;pending&nbsp;acceptance";
<a name="line4163"></a><div class="linenumber">4163</div><div style="width:6em;display:inline-block"></div>logDebug(message);
<a name="line4164"></a><div class="linenumber">4164</div><div style="width:6em;display:inline-block"></div>callFailureCB(self.errCodes.ALREADY_CONNECTED,&nbsp;message);
<a name="line4165"></a><div class="linenumber">4165</div><div style="width:6em;display:inline-block"></div>return;
<a name="line4166"></a><div class="linenumber">4166</div><div style="width:4em;display:inline-block"></div>}
<a name="line4167"></a><div class="linenumber">4167</div>
<a name="line4168"></a><div class="linenumber">4168</div><div style="width:4em;display:inline-block"></div>if&nbsp;(use_fresh_ice_each_peer)&nbsp;{
<a name="line4169"></a><div class="linenumber">4169</div><div style="width:6em;display:inline-block"></div>self.getFreshIceConfig(function(succeeded)&nbsp;{
<a name="line4170"></a><div class="linenumber">4170</div><div style="width:8em;display:inline-block"></div>if&nbsp;(succeeded)&nbsp;{
<a name="line4171"></a><div class="linenumber">4171</div><div style="width:10em;display:inline-block"></div>callBody(otherUser,&nbsp;callSuccessCB,&nbsp;callFailureCB,&nbsp;wasAcceptedCB,&nbsp;streamNames);
<a name="line4172"></a><div class="linenumber">4172</div><div style="width:8em;display:inline-block"></div>}
<a name="line4173"></a><div class="linenumber">4173</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line4174"></a><div class="linenumber">4174</div><div style="width:10em;display:inline-block"></div>callFailureCB(self.errCodes.CALL_ERR,&nbsp;"Attempt&nbsp;to&nbsp;get&nbsp;fresh&nbsp;ice&nbsp;configuration&nbsp;failed");
<a name="line4175"></a><div class="linenumber">4175</div><div style="width:8em;display:inline-block"></div>}
<a name="line4176"></a><div class="linenumber">4176</div><div style="width:6em;display:inline-block"></div>});
<a name="line4177"></a><div class="linenumber">4177</div><div style="width:4em;display:inline-block"></div>}
<a name="line4178"></a><div class="linenumber">4178</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4179"></a><div class="linenumber">4179</div><div style="width:6em;display:inline-block"></div>callBody(otherUser,&nbsp;callSuccessCB,&nbsp;callFailureCB,&nbsp;wasAcceptedCB,&nbsp;streamNames);
<a name="line4180"></a><div class="linenumber">4180</div><div style="width:4em;display:inline-block"></div>}
<a name="line4181"></a><div class="linenumber">4181</div><div style="width:2em;display:inline-block"></div>};
<a name="line4182"></a><div class="linenumber">4182</div>
<a name="line4183"></a><div class="linenumber">4183</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4184"></a><div class="linenumber">4184</div><div style="width:2em;display:inline-block"></div>//
<a name="line4185"></a><div class="linenumber">4185</div><div style="width:2em;display:inline-block"></div>//&nbsp;this&nbsp;function&nbsp;check&nbsp;the&nbsp;deprecated&nbsp;MediaStream.ended&nbsp;attribute
<a name="line4186"></a><div class="linenumber">4186</div><div style="width:2em;display:inline-block"></div>//&nbsp;and&nbsp;new&nbsp;.active.&nbsp;Also&nbsp;fallback&nbsp;.enable&nbsp;on&nbsp;track&nbsp;for&nbsp;Firefox.
<a name="line4187"></a><div class="linenumber">4187</div><div style="width:2em;display:inline-block"></div>//
<a name="line4188"></a><div class="linenumber">4188</div><div style="width:2em;display:inline-block"></div>function&nbsp;isStreamActive(stream)&nbsp;{
<a name="line4189"></a><div class="linenumber">4189</div>
<a name="line4190"></a><div class="linenumber">4190</div><div style="width:4em;display:inline-block"></div>var&nbsp;isActive;
<a name="line4191"></a><div class="linenumber">4191</div>
<a name="line4192"></a><div class="linenumber">4192</div><div style="width:4em;display:inline-block"></div>if&nbsp;(stream.active&nbsp;===&nbsp;true&nbsp;||&nbsp;stream.ended&nbsp;===&nbsp;false)&nbsp;&nbsp;{
<a name="line4193"></a><div class="linenumber">4193</div><div style="width:6em;display:inline-block"></div>isActive&nbsp;=&nbsp;true;
<a name="line4194"></a><div class="linenumber">4194</div><div style="width:4em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line4195"></a><div class="linenumber">4195</div><div style="width:6em;display:inline-block"></div>isActive&nbsp;=&nbsp;stream.getTracks().reduce(function&nbsp;(track)&nbsp;{
<a name="line4196"></a><div class="linenumber">4196</div><div style="width:8em;display:inline-block"></div>return&nbsp;track.enabled;
<a name="line4197"></a><div class="linenumber">4197</div><div style="width:6em;display:inline-block"></div>});
<a name="line4198"></a><div class="linenumber">4198</div><div style="width:4em;display:inline-block"></div>}
<a name="line4199"></a><div class="linenumber">4199</div>
<a name="line4200"></a><div class="linenumber">4200</div><div style="width:4em;display:inline-block"></div>return&nbsp;isActive;
<a name="line4201"></a><div class="linenumber">4201</div><div style="width:2em;display:inline-block"></div>}
<a name="line4202"></a><div class="linenumber">4202</div>
<a name="line4203"></a><div class="linenumber">4203</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4204"></a><div class="linenumber">4204</div><div style="width:2em;display:inline-block"></div>var&nbsp;queuedMessages&nbsp;=&nbsp;{};
<a name="line4205"></a><div class="linenumber">4205</div>
<a name="line4206"></a><div class="linenumber">4206</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4207"></a><div class="linenumber">4207</div><div style="width:2em;display:inline-block"></div>function&nbsp;clearQueuedMessages(caller)&nbsp;{
<a name="line4208"></a><div class="linenumber">4208</div><div style="width:4em;display:inline-block"></div>queuedMessages[caller]&nbsp;=&nbsp;{
<a name="line4209"></a><div class="linenumber">4209</div><div style="width:6em;display:inline-block"></div>candidates:&nbsp;[]
<a name="line4210"></a><div class="linenumber">4210</div><div style="width:4em;display:inline-block"></div>};
<a name="line4211"></a><div class="linenumber">4211</div><div style="width:2em;display:inline-block"></div>}
<a name="line4212"></a><div class="linenumber">4212</div>
<a name="line4213"></a><div class="linenumber">4213</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4214"></a><div class="linenumber">4214</div><div style="width:2em;display:inline-block"></div>function&nbsp;closePeer(otherUser)&nbsp;{
<a name="line4215"></a><div class="linenumber">4215</div>
<a name="line4216"></a><div class="linenumber">4216</div><div style="width:4em;display:inline-block"></div>if&nbsp;(acceptancePending[otherUser])&nbsp;{
<a name="line4217"></a><div class="linenumber">4217</div><div style="width:6em;display:inline-block"></div>delete&nbsp;acceptancePending[otherUser];
<a name="line4218"></a><div class="linenumber">4218</div><div style="width:4em;display:inline-block"></div>}
<a name="line4219"></a><div class="linenumber">4219</div><div style="width:4em;display:inline-block"></div>if&nbsp;(offersPending[otherUser])&nbsp;{
<a name="line4220"></a><div class="linenumber">4220</div><div style="width:6em;display:inline-block"></div>delete&nbsp;offersPending[otherUser];
<a name="line4221"></a><div class="linenumber">4221</div><div style="width:4em;display:inline-block"></div>}
<a name="line4222"></a><div class="linenumber">4222</div>
<a name="line4223"></a><div class="linenumber">4223</div><div style="width:4em;display:inline-block"></div>if&nbsp;(
<a name="line4224"></a><div class="linenumber">4224</div><div style="width:5em;display:inline-block"></div>!peerConns[otherUser].cancelled&nbsp;&amp;&amp;
<a name="line4225"></a><div class="linenumber">4225</div><div style="width:7em;display:inline-block"></div>peerConns[otherUser].pc
<a name="line4226"></a><div class="linenumber">4226</div><div style="width:4em;display:inline-block"></div>)&nbsp;{
<a name="line4227"></a><div class="linenumber">4227</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line4228"></a><div class="linenumber">4228</div><div style="width:8em;display:inline-block"></div>var&nbsp;remoteStreams&nbsp;=&nbsp;peerConns[otherUser].pc.getRemoteStreams();
<a name="line4229"></a><div class="linenumber">4229</div><div style="width:8em;display:inline-block"></div>for&nbsp;(var&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;remoteStreams.length;&nbsp;i++)&nbsp;{
<a name="line4230"></a><div class="linenumber">4230</div><div style="width:10em;display:inline-block"></div>if&nbsp;(isStreamActive(remoteStreams[i]))&nbsp;{
<a name="line4231"></a><div class="linenumber">4231</div><div style="width:12em;display:inline-block"></div>emitOnStreamClosed(otherUser,&nbsp;remoteStreams[i]);
<a name="line4232"></a><div class="linenumber">4232</div><div style="width:12em;display:inline-block"></div>stopStream(remoteStreams[i]);
<a name="line4233"></a><div class="linenumber">4233</div><div style="width:10em;display:inline-block"></div>}
<a name="line4234"></a><div class="linenumber">4234</div><div style="width:8em;display:inline-block"></div>}
<a name="line4235"></a><div class="linenumber">4235</div>
<a name="line4236"></a><div class="linenumber">4236</div><div style="width:8em;display:inline-block"></div>peerConns[otherUser].pc.close();
<a name="line4237"></a><div class="linenumber">4237</div><div style="width:8em;display:inline-block"></div>peerConns[otherUser].cancelled&nbsp;=&nbsp;true;
<a name="line4238"></a><div class="linenumber">4238</div><div style="width:8em;display:inline-block"></div>logDebug("peer&nbsp;closed");
<a name="line4239"></a><div class="linenumber">4239</div><div style="width:6em;display:inline-block"></div>}&nbsp;catch&nbsp;(err)&nbsp;{
<a name="line4240"></a><div class="linenumber">4240</div><div style="width:8em;display:inline-block"></div>logDebug("peer&nbsp;"&nbsp;+&nbsp;otherUser&nbsp;+&nbsp;"&nbsp;close&nbsp;failed:"&nbsp;+&nbsp;err);
<a name="line4241"></a><div class="linenumber">4241</div><div style="width:6em;display:inline-block"></div>}&nbsp;finally&nbsp;{
<a name="line4242"></a><div class="linenumber">4242</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.onPeerClosed)&nbsp;{
<a name="line4243"></a><div class="linenumber">4243</div><div style="width:10em;display:inline-block"></div>self.onPeerClosed(otherUser);
<a name="line4244"></a><div class="linenumber">4244</div><div style="width:8em;display:inline-block"></div>}
<a name="line4245"></a><div class="linenumber">4245</div><div style="width:6em;display:inline-block"></div>}
<a name="line4246"></a><div class="linenumber">4246</div><div style="width:4em;display:inline-block"></div>}
<a name="line4247"></a><div class="linenumber">4247</div><div style="width:2em;display:inline-block"></div>}
<a name="line4248"></a><div class="linenumber">4248</div>
<a name="line4249"></a><div class="linenumber">4249</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4250"></a><div class="linenumber">4250</div><div style="width:2em;display:inline-block"></div>function&nbsp;hangupBody(otherUser)&nbsp;{
<a name="line4251"></a><div class="linenumber">4251</div>
<a name="line4252"></a><div class="linenumber">4252</div><div style="width:4em;display:inline-block"></div>logDebug("Hanging&nbsp;up&nbsp;on&nbsp;"&nbsp;+&nbsp;otherUser);
<a name="line4253"></a><div class="linenumber">4253</div><div style="width:4em;display:inline-block"></div>clearQueuedMessages(otherUser);
<a name="line4254"></a><div class="linenumber">4254</div>
<a name="line4255"></a><div class="linenumber">4255</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line4256"></a><div class="linenumber">4256</div>
<a name="line4257"></a><div class="linenumber">4257</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[otherUser].pc)&nbsp;{
<a name="line4258"></a><div class="linenumber">4258</div><div style="width:8em;display:inline-block"></div>closePeer(otherUser);
<a name="line4259"></a><div class="linenumber">4259</div><div style="width:6em;display:inline-block"></div>}&nbsp;
<a name="line4260"></a><div class="linenumber">4260</div>
<a name="line4261"></a><div class="linenumber">4261</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line4262"></a><div class="linenumber">4262</div><div style="width:8em;display:inline-block"></div>delete&nbsp;peerConns[otherUser];
<a name="line4263"></a><div class="linenumber">4263</div><div style="width:6em;display:inline-block"></div>}
<a name="line4264"></a><div class="linenumber">4264</div>
<a name="line4265"></a><div class="linenumber">4265</div><div style="width:6em;display:inline-block"></div>updateConfigurationInfo();
<a name="line4266"></a><div class="linenumber">4266</div>
<a name="line4267"></a><div class="linenumber">4267</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.webSocket)&nbsp;{
<a name="line4268"></a><div class="linenumber">4268</div><div style="width:8em;display:inline-block"></div>sendSignalling(otherUser,&nbsp;"hangup",&nbsp;null,&nbsp;function()&nbsp;{
<a name="line4269"></a><div class="linenumber">4269</div><div style="width:10em;display:inline-block"></div>logDebug("hangup&nbsp;succeeds");
<a name="line4270"></a><div class="linenumber">4270</div><div style="width:8em;display:inline-block"></div>},&nbsp;function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line4271"></a><div class="linenumber">4271</div><div style="width:10em;display:inline-block"></div>logDebug("hangup&nbsp;failed:"&nbsp;+&nbsp;errorText);
<a name="line4272"></a><div class="linenumber">4272</div><div style="width:10em;display:inline-block"></div>self.showError(errorCode,&nbsp;errorText);
<a name="line4273"></a><div class="linenumber">4273</div><div style="width:8em;display:inline-block"></div>});
<a name="line4274"></a><div class="linenumber">4274</div><div style="width:6em;display:inline-block"></div>}
<a name="line4275"></a><div class="linenumber">4275</div><div style="width:4em;display:inline-block"></div>}
<a name="line4276"></a><div class="linenumber">4276</div><div style="width:2em;display:inline-block"></div>}
<a name="line4277"></a><div class="linenumber">4277</div>
<a name="line4278"></a><div class="linenumber">4278</div>
<a name="line4279"></a><div class="linenumber">4279</div>
<a name="line4280"></a><div class="linenumber">4280</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4281"></a><div class="linenumber">4281</div><div style="width:2em;display:inline-block"></div>*&nbsp;Hang&nbsp;up&nbsp;on&nbsp;a&nbsp;particular&nbsp;user&nbsp;or&nbsp;all&nbsp;users.
<a name="line4282"></a><div class="linenumber">4282</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@param&nbsp;{String}&nbsp;otherUser&nbsp;-&nbsp;the&nbsp;easyrtcid&nbsp;of&nbsp;the&nbsp;person&nbsp;to&nbsp;hang&nbsp;up&nbsp;on.
<a name="line4283"></a><div class="linenumber">4283</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;@example
<a name="line4284"></a><div class="linenumber">4284</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.hangup(someEasyrtcid);
<a name="line4285"></a><div class="linenumber">4285</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4286"></a><div class="linenumber">4286</div><div style="width:2em;display:inline-block"></div>this.hangup&nbsp;=&nbsp;function(otherUser)&nbsp;{
<a name="line4287"></a><div class="linenumber">4287</div><div style="width:4em;display:inline-block"></div>hangupBody(otherUser);
<a name="line4288"></a><div class="linenumber">4288</div><div style="width:4em;display:inline-block"></div>updateConfigurationInfo();
<a name="line4289"></a><div class="linenumber">4289</div><div style="width:2em;display:inline-block"></div>};
<a name="line4290"></a><div class="linenumber">4290</div>
<a name="line4291"></a><div class="linenumber">4291</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4292"></a><div class="linenumber">4292</div><div style="width:2em;display:inline-block"></div>*&nbsp;Hangs&nbsp;up&nbsp;on&nbsp;all&nbsp;current&nbsp;connections.
<a name="line4293"></a><div class="linenumber">4293</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line4294"></a><div class="linenumber">4294</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.hangupAll();
<a name="line4295"></a><div class="linenumber">4295</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4296"></a><div class="linenumber">4296</div><div style="width:2em;display:inline-block"></div>this.hangupAll&nbsp;=&nbsp;function()&nbsp;{
<a name="line4297"></a><div class="linenumber">4297</div>
<a name="line4298"></a><div class="linenumber">4298</div><div style="width:4em;display:inline-block"></div>var&nbsp;sawAConnection&nbsp;=&nbsp;false;
<a name="line4299"></a><div class="linenumber">4299</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;otherUser&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line4300"></a><div class="linenumber">4300</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!peerConns.hasOwnProperty(otherUser))&nbsp;{
<a name="line4301"></a><div class="linenumber">4301</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line4302"></a><div class="linenumber">4302</div><div style="width:6em;display:inline-block"></div>}
<a name="line4303"></a><div class="linenumber">4303</div><div style="width:6em;display:inline-block"></div>sawAConnection&nbsp;=&nbsp;true;
<a name="line4304"></a><div class="linenumber">4304</div><div style="width:6em;display:inline-block"></div>hangupBody(otherUser);
<a name="line4305"></a><div class="linenumber">4305</div><div style="width:4em;display:inline-block"></div>}
<a name="line4306"></a><div class="linenumber">4306</div>
<a name="line4307"></a><div class="linenumber">4307</div><div style="width:4em;display:inline-block"></div>if&nbsp;(sawAConnection)&nbsp;{
<a name="line4308"></a><div class="linenumber">4308</div><div style="width:6em;display:inline-block"></div>updateConfigurationInfo();
<a name="line4309"></a><div class="linenumber">4309</div><div style="width:4em;display:inline-block"></div>}
<a name="line4310"></a><div class="linenumber">4310</div><div style="width:2em;display:inline-block"></div>};
<a name="line4311"></a><div class="linenumber">4311</div>
<a name="line4312"></a><div class="linenumber">4312</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4313"></a><div class="linenumber">4313</div><div style="width:2em;display:inline-block"></div>*&nbsp;Checks&nbsp;to&nbsp;see&nbsp;if&nbsp;data&nbsp;channels&nbsp;work&nbsp;between&nbsp;two&nbsp;peers.
<a name="line4314"></a><div class="linenumber">4314</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;otherUser&nbsp;-&nbsp;the&nbsp;other&nbsp;peer.
<a name="line4315"></a><div class="linenumber">4315</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Boolean}&nbsp;true&nbsp;if&nbsp;data&nbsp;channels&nbsp;work&nbsp;and&nbsp;are&nbsp;ready&nbsp;to&nbsp;be&nbsp;used
<a name="line4316"></a><div class="linenumber">4316</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;between&nbsp;the&nbsp;two&nbsp;peers.
<a name="line4317"></a><div class="linenumber">4317</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4318"></a><div class="linenumber">4318</div><div style="width:2em;display:inline-block"></div>this.doesDataChannelWork&nbsp;=&nbsp;function(otherUser)&nbsp;{
<a name="line4319"></a><div class="linenumber">4319</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[otherUser])&nbsp;{
<a name="line4320"></a><div class="linenumber">4320</div><div style="width:6em;display:inline-block"></div>return&nbsp;false;
<a name="line4321"></a><div class="linenumber">4321</div><div style="width:4em;display:inline-block"></div>}
<a name="line4322"></a><div class="linenumber">4322</div><div style="width:4em;display:inline-block"></div>return&nbsp;!!peerConns[otherUser].dataChannelReady;
<a name="line4323"></a><div class="linenumber">4323</div><div style="width:2em;display:inline-block"></div>};
<a name="line4324"></a><div class="linenumber">4324</div>
<a name="line4325"></a><div class="linenumber">4325</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4326"></a><div class="linenumber">4326</div><div style="width:2em;display:inline-block"></div>*&nbsp;Return&nbsp;the&nbsp;media&nbsp;stream&nbsp;shared&nbsp;by&nbsp;a&nbsp;particular&nbsp;peer.&nbsp;This&nbsp;is&nbsp;needed&nbsp;when&nbsp;you
<a name="line4327"></a><div class="linenumber">4327</div><div style="width:2em;display:inline-block"></div>*&nbsp;add&nbsp;a&nbsp;stream&nbsp;in&nbsp;the&nbsp;middle&nbsp;of&nbsp;a&nbsp;call.
<a name="line4328"></a><div class="linenumber">4328</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid&nbsp;the&nbsp;peer.
<a name="line4329"></a><div class="linenumber">4329</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;remoteStreamName&nbsp;an&nbsp;optional&nbsp;argument&nbsp;supplying&nbsp;the&nbsp;streamName.
<a name="line4330"></a><div class="linenumber">4330</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;A&nbsp;mediaStream.
<a name="line4331"></a><div class="linenumber">4331</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4332"></a><div class="linenumber">4332</div><div style="width:2em;display:inline-block"></div>this.getRemoteStream&nbsp;=&nbsp;function(easyrtcid,&nbsp;remoteStreamName)&nbsp;{
<a name="line4333"></a><div class="linenumber">4333</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[easyrtcid])&nbsp;{
<a name="line4334"></a><div class="linenumber">4334</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"attempt&nbsp;to&nbsp;get&nbsp;stream&nbsp;of&nbsp;uncalled&nbsp;party");
<a name="line4335"></a><div class="linenumber">4335</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Developer&nbsp;err:&nbsp;no&nbsp;such&nbsp;stream";
<a name="line4336"></a><div class="linenumber">4336</div><div style="width:4em;display:inline-block"></div>}
<a name="line4337"></a><div class="linenumber">4337</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4338"></a><div class="linenumber">4338</div><div style="width:6em;display:inline-block"></div>return&nbsp;getRemoteStreamByName(peerConns[easyrtcid],&nbsp;easyrtcid,&nbsp;remoteStreamName);
<a name="line4339"></a><div class="linenumber">4339</div><div style="width:4em;display:inline-block"></div>}
<a name="line4340"></a><div class="linenumber">4340</div><div style="width:2em;display:inline-block"></div>};
<a name="line4341"></a><div class="linenumber">4341</div>
<a name="line4342"></a><div class="linenumber">4342</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4343"></a><div class="linenumber">4343</div><div style="width:2em;display:inline-block"></div>*&nbsp;Assign&nbsp;a&nbsp;local&nbsp;streamName&nbsp;to&nbsp;a&nbsp;remote&nbsp;stream&nbsp;so&nbsp;that&nbsp;it&nbsp;can&nbsp;be&nbsp;forwarded&nbsp;to&nbsp;other&nbsp;callers.
<a name="line4344"></a><div class="linenumber">4344</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcid&nbsp;the&nbsp;peer&nbsp;supplying&nbsp;the&nbsp;remote&nbsp;stream
<a name="line4345"></a><div class="linenumber">4345</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;remoteStreamName&nbsp;the&nbsp;streamName&nbsp;supplied&nbsp;by&nbsp;the&nbsp;peer.
<a name="line4346"></a><div class="linenumber">4346</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;localStreamName&nbsp;streamName&nbsp;used&nbsp;when&nbsp;passing&nbsp;the&nbsp;stream&nbsp;to&nbsp;other&nbsp;peers.
<a name="line4347"></a><div class="linenumber">4347</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line4348"></a><div class="linenumber">4348</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.makeLocalStreamFromRemoteStream(sourcePeer,&nbsp;"default",&nbsp;"forwardedStream");
<a name="line4349"></a><div class="linenumber">4349</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.call(nextPeer,&nbsp;callSuccessCB,&nbsp;callFailureCB,&nbsp;wasAcceptedCB,&nbsp;["forwardedStream"]);
<a name="line4350"></a><div class="linenumber">4350</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4351"></a><div class="linenumber">4351</div><div style="width:2em;display:inline-block"></div>this.makeLocalStreamFromRemoteStream&nbsp;=&nbsp;function(easyrtcid,&nbsp;remoteStreamName,&nbsp;localStreamName)&nbsp;{
<a name="line4352"></a><div class="linenumber">4352</div><div style="width:4em;display:inline-block"></div>var&nbsp;remoteStream;
<a name="line4353"></a><div class="linenumber">4353</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[easyrtcid].pc)&nbsp;{
<a name="line4354"></a><div class="linenumber">4354</div><div style="width:6em;display:inline-block"></div>remoteStream&nbsp;=&nbsp;getRemoteStreamByName(peerConns[easyrtcid],&nbsp;easyrtcid,&nbsp;remoteStreamName);
<a name="line4355"></a><div class="linenumber">4355</div><div style="width:6em;display:inline-block"></div>if&nbsp;(remoteStream)&nbsp;{
<a name="line4356"></a><div class="linenumber">4356</div><div style="width:8em;display:inline-block"></div>registerLocalMediaStreamByName(remoteStream,&nbsp;localStreamName);
<a name="line4357"></a><div class="linenumber">4357</div><div style="width:6em;display:inline-block"></div>}
<a name="line4358"></a><div class="linenumber">4358</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line4359"></a><div class="linenumber">4359</div><div style="width:8em;display:inline-block"></div>throw&nbsp;"Developer&nbsp;err:&nbsp;no&nbsp;such&nbsp;stream";
<a name="line4360"></a><div class="linenumber">4360</div><div style="width:6em;display:inline-block"></div>}
<a name="line4361"></a><div class="linenumber">4361</div><div style="width:4em;display:inline-block"></div>}
<a name="line4362"></a><div class="linenumber">4362</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4363"></a><div class="linenumber">4363</div><div style="width:6em;display:inline-block"></div>throw&nbsp;"Developer&nbsp;err:&nbsp;no&nbsp;such&nbsp;peer&nbsp;";
<a name="line4364"></a><div class="linenumber">4364</div><div style="width:4em;display:inline-block"></div>}
<a name="line4365"></a><div class="linenumber">4365</div><div style="width:2em;display:inline-block"></div>};
<a name="line4366"></a><div class="linenumber">4366</div>
<a name="line4367"></a><div class="linenumber">4367</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4368"></a><div class="linenumber">4368</div><div style="width:2em;display:inline-block"></div>*&nbsp;Add&nbsp;a&nbsp;named&nbsp;local&nbsp;stream&nbsp;to&nbsp;a&nbsp;call.
<a name="line4369"></a><div class="linenumber">4369</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;easyrtcId&nbsp;The&nbsp;id&nbsp;of&nbsp;client&nbsp;receiving&nbsp;the&nbsp;stream.
<a name="line4370"></a><div class="linenumber">4370</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;streamName&nbsp;The&nbsp;name&nbsp;of&nbsp;the&nbsp;stream.
<a name="line4371"></a><div class="linenumber">4371</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;receiptHandler&nbsp;is&nbsp;a&nbsp;function&nbsp;that&nbsp;gets&nbsp;called&nbsp;when&nbsp;the&nbsp;other&nbsp;side&nbsp;sends&nbsp;a&nbsp;message
<a name="line4372"></a><div class="linenumber">4372</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;that&nbsp;the&nbsp;stream&nbsp;has&nbsp;been&nbsp;received.&nbsp;The&nbsp;receiptHandler&nbsp;gets&nbsp;called&nbsp;with&nbsp;an&nbsp;easyrtcid&nbsp;and&nbsp;a&nbsp;stream&nbsp;name.&nbsp;This
<a name="line4373"></a><div class="linenumber">4373</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;argument&nbsp;is&nbsp;optional.
<a name="line4374"></a><div class="linenumber">4374</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4375"></a><div class="linenumber">4375</div><div style="width:2em;display:inline-block"></div>this.addStreamToCall&nbsp;=&nbsp;function(easyrtcId,&nbsp;streamName,&nbsp;receiptHandler)&nbsp;{
<a name="line4376"></a><div class="linenumber">4376</div><div style="width:4em;display:inline-block"></div>if(&nbsp;!streamName)&nbsp;{
<a name="line4377"></a><div class="linenumber">4377</div><div style="width:6em;display:inline-block"></div>streamName&nbsp;=&nbsp;"default";
<a name="line4378"></a><div class="linenumber">4378</div><div style="width:4em;display:inline-block"></div>}
<a name="line4379"></a><div class="linenumber">4379</div><div style="width:4em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;getLocalMediaStreamByName(streamName);
<a name="line4380"></a><div class="linenumber">4380</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!stream)&nbsp;{
<a name="line4381"></a><div class="linenumber">4381</div><div style="width:6em;display:inline-block"></div>logDebug("attempt&nbsp;to&nbsp;add&nbsp;nonexistent&nbsp;stream&nbsp;"&nbsp;+&nbsp;streamName);
<a name="line4382"></a><div class="linenumber">4382</div><div style="width:4em;display:inline-block"></div>}
<a name="line4383"></a><div class="linenumber">4383</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(!peerConns[easyrtcId]&nbsp;||&nbsp;!peerConns[easyrtcId].pc)&nbsp;{
<a name="line4384"></a><div class="linenumber">4384</div><div style="width:6em;display:inline-block"></div>logDebug("Can't&nbsp;add&nbsp;stream&nbsp;before&nbsp;a&nbsp;call&nbsp;has&nbsp;started.");
<a name="line4385"></a><div class="linenumber">4385</div><div style="width:4em;display:inline-block"></div>}
<a name="line4386"></a><div class="linenumber">4386</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4387"></a><div class="linenumber">4387</div><div style="width:6em;display:inline-block"></div>var&nbsp;pc&nbsp;=&nbsp;peerConns[easyrtcId].pc;
<a name="line4388"></a><div class="linenumber">4388</div><div style="width:6em;display:inline-block"></div>peerConns[easyrtcId].enableNegotiateListener&nbsp;=&nbsp;true;
<a name="line4389"></a><div class="linenumber">4389</div><div style="width:6em;display:inline-block"></div>pc.addStream(stream);
<a name="line4390"></a><div class="linenumber">4390</div><div style="width:6em;display:inline-block"></div>if&nbsp;(receiptHandler)&nbsp;{
<a name="line4391"></a><div class="linenumber">4391</div><div style="width:8em;display:inline-block"></div>peerConns[easyrtcId].streamsAddedAcks[streamName]&nbsp;=&nbsp;receiptHandler;
<a name="line4392"></a><div class="linenumber">4392</div><div style="width:6em;display:inline-block"></div>}
<a name="line4393"></a><div class="linenumber">4393</div><div style="width:4em;display:inline-block"></div>}
<a name="line4394"></a><div class="linenumber">4394</div><div style="width:2em;display:inline-block"></div>};
<a name="line4395"></a><div class="linenumber">4395</div>
<a name="line4396"></a><div class="linenumber">4396</div><div style="width:2em;display:inline-block"></div>//
<a name="line4397"></a><div class="linenumber">4397</div><div style="width:2em;display:inline-block"></div>//&nbsp;these&nbsp;three&nbsp;listeners&nbsp;support&nbsp;the&nbsp;ability&nbsp;to&nbsp;add/remove&nbsp;additional&nbsp;media&nbsp;streams&nbsp;on&nbsp;the&nbsp;fly.
<a name="line4398"></a><div class="linenumber">4398</div><div style="width:2em;display:inline-block"></div>//
<a name="line4399"></a><div class="linenumber">4399</div><div style="width:2em;display:inline-block"></div>this.setPeerListener(function(easyrtcid,&nbsp;msgType,&nbsp;msgData)&nbsp;{
<a name="line4400"></a><div class="linenumber">4400</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[easyrtcid]&nbsp;||&nbsp;!peerConns[easyrtcid].pc)&nbsp;{
<a name="line4401"></a><div class="linenumber">4401</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,
<a name="line4402"></a><div class="linenumber">4402</div><div style="width:9em;display:inline-block"></div>"Attempt&nbsp;to&nbsp;add&nbsp;additional&nbsp;stream&nbsp;before&nbsp;establishing&nbsp;the&nbsp;base&nbsp;call.");
<a name="line4403"></a><div class="linenumber">4403</div><div style="width:4em;display:inline-block"></div>}
<a name="line4404"></a><div class="linenumber">4404</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4405"></a><div class="linenumber">4405</div><div style="width:6em;display:inline-block"></div>var&nbsp;sdp&nbsp;=&nbsp;msgData.sdp;
<a name="line4406"></a><div class="linenumber">4406</div><div style="width:6em;display:inline-block"></div>var&nbsp;pc&nbsp;=&nbsp;peerConns[easyrtcid].pc;
<a name="line4407"></a><div class="linenumber">4407</div>
<a name="line4408"></a><div class="linenumber">4408</div><div style="width:6em;display:inline-block"></div>var&nbsp;setLocalAndSendMessage1&nbsp;=&nbsp;function(sessionDescription)&nbsp;{
<a name="line4409"></a><div class="linenumber">4409</div><div style="width:8em;display:inline-block"></div>var&nbsp;sendAnswer&nbsp;=&nbsp;function()&nbsp;{
<a name="line4410"></a><div class="linenumber">4410</div><div style="width:9em;display:inline-block"></div>logDebug("sending&nbsp;answer");
<a name="line4411"></a><div class="linenumber">4411</div>
<a name="line4412"></a><div class="linenumber">4412</div><div style="width:9em;display:inline-block"></div>function&nbsp;onSignalSuccess()&nbsp;{
<a name="line4413"></a><div class="linenumber">4413</div><div style="width:12em;display:inline-block"></div>logDebug("sending&nbsp;answer&nbsp;succeeded");
<a name="line4414"></a><div class="linenumber">4414</div>
<a name="line4415"></a><div class="linenumber">4415</div><div style="width:9em;display:inline-block"></div>}
<a name="line4416"></a><div class="linenumber">4416</div>
<a name="line4417"></a><div class="linenumber">4417</div><div style="width:9em;display:inline-block"></div>function&nbsp;onSignalFailure(errorCode,&nbsp;errorText)&nbsp;{
<a name="line4418"></a><div class="linenumber">4418</div><div style="width:12em;display:inline-block"></div>logDebug("sending&nbsp;answer&nbsp;failed");
<a name="line4419"></a><div class="linenumber">4419</div>
<a name="line4420"></a><div class="linenumber">4420</div><div style="width:11em;display:inline-block"></div>delete&nbsp;peerConns[easyrtcid];
<a name="line4421"></a><div class="linenumber">4421</div><div style="width:11em;display:inline-block"></div>self.showError(errorCode,&nbsp;errorText);
<a name="line4422"></a><div class="linenumber">4422</div><div style="width:9em;display:inline-block"></div>}
<a name="line4423"></a><div class="linenumber">4423</div>
<a name="line4424"></a><div class="linenumber">4424</div><div style="width:9em;display:inline-block"></div>sendSignalling(easyrtcid,&nbsp;"answer",&nbsp;sessionDescription,
<a name="line4425"></a><div class="linenumber">4425</div><div style="width:13em;display:inline-block"></div>onSignalSuccess,&nbsp;onSignalFailure);
<a name="line4426"></a><div class="linenumber">4426</div><div style="width:9em;display:inline-block"></div>peerConns[easyrtcid].connectionAccepted&nbsp;=&nbsp;true;
<a name="line4427"></a><div class="linenumber">4427</div><div style="width:9em;display:inline-block"></div>sendQueuedCandidates(easyrtcid,&nbsp;onSignalSuccess,&nbsp;onSignalFailure);
<a name="line4428"></a><div class="linenumber">4428</div><div style="width:7em;display:inline-block"></div>};
<a name="line4429"></a><div class="linenumber">4429</div>
<a name="line4430"></a><div class="linenumber">4430</div><div style="width:7em;display:inline-block"></div>if&nbsp;(sdpLocalFilter)&nbsp;{
<a name="line4431"></a><div class="linenumber">4431</div><div style="width:9em;display:inline-block"></div>sessionDescription.sdp&nbsp;=&nbsp;sdpLocalFilter(sessionDescription.sdp);
<a name="line4432"></a><div class="linenumber">4432</div><div style="width:7em;display:inline-block"></div>}
<a name="line4433"></a><div class="linenumber">4433</div><div style="width:7em;display:inline-block"></div>pc.setLocalDescription(sessionDescription,&nbsp;sendAnswer,&nbsp;function(message)&nbsp;{
<a name="line4434"></a><div class="linenumber">4434</div><div style="width:9em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"setLocalDescription:&nbsp;"&nbsp;+&nbsp;msgData);
<a name="line4435"></a><div class="linenumber">4435</div><div style="width:7em;display:inline-block"></div>});
<a name="line4436"></a><div class="linenumber">4436</div><div style="width:6em;display:inline-block"></div>};
<a name="line4437"></a><div class="linenumber">4437</div>
<a name="line4438"></a><div class="linenumber">4438</div><div style="width:6em;display:inline-block"></div>var&nbsp;invokeCreateAnswer&nbsp;=&nbsp;function()&nbsp;{
<a name="line4439"></a><div class="linenumber">4439</div><div style="width:7em;display:inline-block"></div>pc.createAnswer(setLocalAndSendMessage1,
<a name="line4440"></a><div class="linenumber">4440</div><div style="width:10em;display:inline-block"></div>function(message)&nbsp;{
<a name="line4441"></a><div class="linenumber">4441</div><div style="width:12em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"create-answer:&nbsp;"&nbsp;+&nbsp;message);
<a name="line4442"></a><div class="linenumber">4442</div><div style="width:10em;display:inline-block"></div>},
<a name="line4443"></a><div class="linenumber">4443</div><div style="width:10em;display:inline-block"></div>receivedMediaConstraints);
<a name="line4444"></a><div class="linenumber">4444</div><div style="width:7em;display:inline-block"></div>self.sendPeerMessage(easyrtcid,&nbsp;"__gotAddedMediaStream",&nbsp;{sdp:&nbsp;sdp});
<a name="line4445"></a><div class="linenumber">4445</div><div style="width:6em;display:inline-block"></div>};
<a name="line4446"></a><div class="linenumber">4446</div>
<a name="line4447"></a><div class="linenumber">4447</div><div style="width:6em;display:inline-block"></div>logDebug("about&nbsp;to&nbsp;call&nbsp;setRemoteDescription&nbsp;in&nbsp;doAnswer");
<a name="line4448"></a><div class="linenumber">4448</div>
<a name="line4449"></a><div class="linenumber">4449</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line4450"></a><div class="linenumber">4450</div>
<a name="line4451"></a><div class="linenumber">4451</div><div style="width:8em;display:inline-block"></div>if&nbsp;(sdpRemoteFilter)&nbsp;{
<a name="line4452"></a><div class="linenumber">4452</div><div style="width:10em;display:inline-block"></div>sdp.sdp&nbsp;=&nbsp;sdpRemoteFilter(sdp.sdp);
<a name="line4453"></a><div class="linenumber">4453</div><div style="width:8em;display:inline-block"></div>}
<a name="line4454"></a><div class="linenumber">4454</div><div style="width:8em;display:inline-block"></div>pc.setRemoteDescription(new&nbsp;RTCSessionDescription(sdp),
<a name="line4455"></a><div class="linenumber">4455</div><div style="width:9em;display:inline-block"></div>invokeCreateAnswer,&nbsp;function(message)&nbsp;{
<a name="line4456"></a><div class="linenumber">4456</div><div style="width:10em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"set-remote-description:&nbsp;"&nbsp;+&nbsp;message);
<a name="line4457"></a><div class="linenumber">4457</div><div style="width:8em;display:inline-block"></div>});
<a name="line4458"></a><div class="linenumber">4458</div><div style="width:6em;display:inline-block"></div>}&nbsp;catch&nbsp;(srdError)&nbsp;{
<a name="line4459"></a><div class="linenumber">4459</div><div style="width:8em;display:inline-block"></div>logDebug("saw&nbsp;exception&nbsp;in&nbsp;setRemoteDescription",&nbsp;srdError);
<a name="line4460"></a><div class="linenumber">4460</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"setRemoteDescription&nbsp;failed:&nbsp;"&nbsp;+&nbsp;srdError.message);
<a name="line4461"></a><div class="linenumber">4461</div><div style="width:6em;display:inline-block"></div>}
<a name="line4462"></a><div class="linenumber">4462</div><div style="width:4em;display:inline-block"></div>}
<a name="line4463"></a><div class="linenumber">4463</div><div style="width:2em;display:inline-block"></div>},&nbsp;"__addedMediaStream");
<a name="line4464"></a><div class="linenumber">4464</div>
<a name="line4465"></a><div class="linenumber">4465</div><div style="width:2em;display:inline-block"></div>this.setPeerListener(function(easyrtcid,&nbsp;msgType,&nbsp;msgData)&nbsp;{
<a name="line4466"></a><div class="linenumber">4466</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[easyrtcid]&nbsp;||&nbsp;!peerConns[easyrtcid].pc)&nbsp;{
<a name="line4467"></a><div class="linenumber">4467</div><div style="width:6em;display:inline-block"></div>logDebug("setPeerListener&nbsp;failed:&nbsp;__gotAddedMediaStream&nbsp;Unknow&nbsp;easyrtcid&nbsp;"&nbsp;+&nbsp;easyrtcid);
<a name="line4468"></a><div class="linenumber">4468</div><div style="width:4em;display:inline-block"></div>}
<a name="line4469"></a><div class="linenumber">4469</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4470"></a><div class="linenumber">4470</div><div style="width:6em;display:inline-block"></div>var&nbsp;sdp&nbsp;=&nbsp;msgData.sdp;
<a name="line4471"></a><div class="linenumber">4471</div><div style="width:6em;display:inline-block"></div>if&nbsp;(sdpRemoteFilter)&nbsp;{
<a name="line4472"></a><div class="linenumber">4472</div><div style="width:8em;display:inline-block"></div>sdp.sdp&nbsp;=&nbsp;sdpRemoteFilter(sdp.sdp);
<a name="line4473"></a><div class="linenumber">4473</div><div style="width:6em;display:inline-block"></div>}
<a name="line4474"></a><div class="linenumber">4474</div><div style="width:6em;display:inline-block"></div>var&nbsp;pc&nbsp;=&nbsp;peerConns[easyrtcid].pc;
<a name="line4475"></a><div class="linenumber">4475</div><div style="width:6em;display:inline-block"></div>pc.setRemoteDescription(new&nbsp;RTCSessionDescription(sdp),&nbsp;function(){},
<a name="line4476"></a><div class="linenumber">4476</div><div style="width:10em;display:inline-block"></div>function(message)&nbsp;{
<a name="line4477"></a><div class="linenumber">4477</div><div style="width:11em;display:inline-block"></div>self.showError(self.errCodes.INTERNAL_ERR,&nbsp;"set-remote-description:&nbsp;"&nbsp;+&nbsp;message);
<a name="line4478"></a><div class="linenumber">4478</div><div style="width:10em;display:inline-block"></div>});
<a name="line4479"></a><div class="linenumber">4479</div><div style="width:4em;display:inline-block"></div>}
<a name="line4480"></a><div class="linenumber">4480</div>
<a name="line4481"></a><div class="linenumber">4481</div><div style="width:2em;display:inline-block"></div>},&nbsp;"__gotAddedMediaStream");
<a name="line4482"></a><div class="linenumber">4482</div>
<a name="line4483"></a><div class="linenumber">4483</div><div style="width:2em;display:inline-block"></div>this.setPeerListener(function(easyrtcid,&nbsp;msgType,&nbsp;msgData)&nbsp;{
<a name="line4484"></a><div class="linenumber">4484</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!peerConns[easyrtcid]&nbsp;||&nbsp;!peerConns[easyrtcid].pc)&nbsp;{
<a name="line4485"></a><div class="linenumber">4485</div><div style="width:6em;display:inline-block"></div>logDebug("setPeerListener&nbsp;failed:&nbsp;__closingMediaStream&nbsp;Unknow&nbsp;easyrtcid&nbsp;"&nbsp;+&nbsp;easyrtcid);
<a name="line4486"></a><div class="linenumber">4486</div><div style="width:4em;display:inline-block"></div>}
<a name="line4487"></a><div class="linenumber">4487</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4488"></a><div class="linenumber">4488</div><div style="width:6em;display:inline-block"></div>var&nbsp;stream&nbsp;=&nbsp;getRemoteStreamByName(peerConns[easyrtcid],&nbsp;easyrtcid,&nbsp;msgData.streamName);
<a name="line4489"></a><div class="linenumber">4489</div><div style="width:6em;display:inline-block"></div>if&nbsp;(stream)&nbsp;{
<a name="line4490"></a><div class="linenumber">4490</div><div style="width:8em;display:inline-block"></div>onRemoveStreamHelper(easyrtcid,&nbsp;stream);
<a name="line4491"></a><div class="linenumber">4491</div><div style="width:8em;display:inline-block"></div>stopStream(stream);
<a name="line4492"></a><div class="linenumber">4492</div><div style="width:6em;display:inline-block"></div>}
<a name="line4493"></a><div class="linenumber">4493</div><div style="width:4em;display:inline-block"></div>}
<a name="line4494"></a><div class="linenumber">4494</div>
<a name="line4495"></a><div class="linenumber">4495</div><div style="width:2em;display:inline-block"></div>},&nbsp;"__closingMediaStream");
<a name="line4496"></a><div class="linenumber">4496</div>
<a name="line4497"></a><div class="linenumber">4497</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4498"></a><div class="linenumber">4498</div><div style="width:2em;display:inline-block"></div>this.dumpPeerConnectionInfo&nbsp;=&nbsp;function()&nbsp;{
<a name="line4499"></a><div class="linenumber">4499</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line4500"></a><div class="linenumber">4500</div><div style="width:4em;display:inline-block"></div>for&nbsp;(var&nbsp;peer&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line4501"></a><div class="linenumber">4501</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns.hasOwnProperty(peer))&nbsp;{
<a name="line4502"></a><div class="linenumber">4502</div><div style="width:8em;display:inline-block"></div>var&nbsp;pc&nbsp;=&nbsp;peerConns[peer].pc;
<a name="line4503"></a><div class="linenumber">4503</div><div style="width:8em;display:inline-block"></div>var&nbsp;remotes&nbsp;=&nbsp;pc.getRemoteStreams();
<a name="line4504"></a><div class="linenumber">4504</div><div style="width:8em;display:inline-block"></div>var&nbsp;remoteIds&nbsp;=&nbsp;[];
<a name="line4505"></a><div class="linenumber">4505</div><div style="width:8em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;remotes.length;&nbsp;i++)&nbsp;{
<a name="line4506"></a><div class="linenumber">4506</div><div style="width:10em;display:inline-block"></div>remoteIds.push(remotes[i].id);
<a name="line4507"></a><div class="linenumber">4507</div><div style="width:8em;display:inline-block"></div>}
<a name="line4508"></a><div class="linenumber">4508</div><div style="width:8em;display:inline-block"></div>var&nbsp;locals&nbsp;=&nbsp;pc.getLocalStreams();
<a name="line4509"></a><div class="linenumber">4509</div><div style="width:8em;display:inline-block"></div>var&nbsp;localIds&nbsp;=&nbsp;[];
<a name="line4510"></a><div class="linenumber">4510</div><div style="width:8em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;locals.length;&nbsp;i++)&nbsp;{
<a name="line4511"></a><div class="linenumber">4511</div><div style="width:10em;display:inline-block"></div>localIds.push(locals[i].id);
<a name="line4512"></a><div class="linenumber">4512</div><div style="width:8em;display:inline-block"></div>}
<a name="line4513"></a><div class="linenumber">4513</div>
<a name="line4514"></a><div class="linenumber">4514</div><div style="width:8em;display:inline-block"></div>logDebug("For&nbsp;peer&nbsp;"&nbsp;+&nbsp;peer);
<a name="line4515"></a><div class="linenumber">4515</div><div style="width:8em;display:inline-block"></div>logDebug("&nbsp;&nbsp;&nbsp;&nbsp;"&nbsp;+&nbsp;JSON.stringify({local:&nbsp;localIds,&nbsp;remote:&nbsp;remoteIds}));
<a name="line4516"></a><div class="linenumber">4516</div><div style="width:6em;display:inline-block"></div>}
<a name="line4517"></a><div class="linenumber">4517</div><div style="width:4em;display:inline-block"></div>}
<a name="line4518"></a><div class="linenumber">4518</div><div style="width:2em;display:inline-block"></div>};
<a name="line4519"></a><div class="linenumber">4519</div>
<a name="line4520"></a><div class="linenumber">4520</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4521"></a><div class="linenumber">4521</div><div style="width:2em;display:inline-block"></div>function&nbsp;onRemoteHangup(otherUser)&nbsp;{
<a name="line4522"></a><div class="linenumber">4522</div>
<a name="line4523"></a><div class="linenumber">4523</div><div style="width:4em;display:inline-block"></div>logDebug("Saw&nbsp;onRemote&nbsp;hangup&nbsp;event");
<a name="line4524"></a><div class="linenumber">4524</div><div style="width:4em;display:inline-block"></div>clearQueuedMessages(otherUser);
<a name="line4525"></a><div class="linenumber">4525</div>
<a name="line4526"></a><div class="linenumber">4526</div><div style="width:4em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line4527"></a><div class="linenumber">4527</div>
<a name="line4528"></a><div class="linenumber">4528</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[otherUser].pc)&nbsp;{
<a name="line4529"></a><div class="linenumber">4529</div><div style="width:8em;display:inline-block"></div>closePeer(otherUser);
<a name="line4530"></a><div class="linenumber">4530</div><div style="width:6em;display:inline-block"></div>}
<a name="line4531"></a><div class="linenumber">4531</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line4532"></a><div class="linenumber">4532</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.callCancelled)&nbsp;{
<a name="line4533"></a><div class="linenumber">4533</div><div style="width:10em;display:inline-block"></div>self.callCancelled(otherUser,&nbsp;true);
<a name="line4534"></a><div class="linenumber">4534</div><div style="width:8em;display:inline-block"></div>}
<a name="line4535"></a><div class="linenumber">4535</div><div style="width:6em;display:inline-block"></div>}
<a name="line4536"></a><div class="linenumber">4536</div>
<a name="line4537"></a><div class="linenumber">4537</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[otherUser])&nbsp;{
<a name="line4538"></a><div class="linenumber">4538</div><div style="width:8em;display:inline-block"></div>delete&nbsp;peerConns[otherUser];
<a name="line4539"></a><div class="linenumber">4539</div><div style="width:6em;display:inline-block"></div>}
<a name="line4540"></a><div class="linenumber">4540</div><div style="width:4em;display:inline-block"></div>}
<a name="line4541"></a><div class="linenumber">4541</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4542"></a><div class="linenumber">4542</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.callCancelled)&nbsp;{
<a name="line4543"></a><div class="linenumber">4543</div><div style="width:8em;display:inline-block"></div>self.callCancelled(otherUser,&nbsp;true);
<a name="line4544"></a><div class="linenumber">4544</div><div style="width:6em;display:inline-block"></div>}
<a name="line4545"></a><div class="linenumber">4545</div><div style="width:4em;display:inline-block"></div>}
<a name="line4546"></a><div class="linenumber">4546</div><div style="width:2em;display:inline-block"></div>}
<a name="line4547"></a><div class="linenumber">4547</div>
<a name="line4548"></a><div class="linenumber">4548</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4549"></a><div class="linenumber">4549</div><div style="width:2em;display:inline-block"></div>//
<a name="line4550"></a><div class="linenumber">4550</div><div style="width:2em;display:inline-block"></div>//&nbsp;checks&nbsp;to&nbsp;see&nbsp;if&nbsp;a&nbsp;particular&nbsp;peer&nbsp;is&nbsp;in&nbsp;any&nbsp;room&nbsp;at&nbsp;all.
<a name="line4551"></a><div class="linenumber">4551</div><div style="width:2em;display:inline-block"></div>//
<a name="line4552"></a><div class="linenumber">4552</div><div style="width:2em;display:inline-block"></div>function&nbsp;isPeerInAnyRoom(id)&nbsp;{
<a name="line4553"></a><div class="linenumber">4553</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomName;
<a name="line4554"></a><div class="linenumber">4554</div><div style="width:4em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;lastLoggedInList)&nbsp;{
<a name="line4555"></a><div class="linenumber">4555</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!lastLoggedInList.hasOwnProperty(roomName))&nbsp;{
<a name="line4556"></a><div class="linenumber">4556</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line4557"></a><div class="linenumber">4557</div><div style="width:6em;display:inline-block"></div>}
<a name="line4558"></a><div class="linenumber">4558</div><div style="width:6em;display:inline-block"></div>if&nbsp;(lastLoggedInList[roomName][id])&nbsp;{
<a name="line4559"></a><div class="linenumber">4559</div><div style="width:8em;display:inline-block"></div>return&nbsp;true;
<a name="line4560"></a><div class="linenumber">4560</div><div style="width:6em;display:inline-block"></div>}
<a name="line4561"></a><div class="linenumber">4561</div><div style="width:4em;display:inline-block"></div>}
<a name="line4562"></a><div class="linenumber">4562</div><div style="width:4em;display:inline-block"></div>return&nbsp;false;
<a name="line4563"></a><div class="linenumber">4563</div><div style="width:2em;display:inline-block"></div>}
<a name="line4564"></a><div class="linenumber">4564</div>
<a name="line4565"></a><div class="linenumber">4565</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4566"></a><div class="linenumber">4566</div><div style="width:2em;display:inline-block"></div>*&nbsp;Checks&nbsp;to&nbsp;see&nbsp;if&nbsp;a&nbsp;particular&nbsp;peer&nbsp;is&nbsp;present&nbsp;in&nbsp;any&nbsp;room.
<a name="line4567"></a><div class="linenumber">4567</div><div style="width:2em;display:inline-block"></div>*&nbsp;If&nbsp;it&nbsp;isn't,&nbsp;we&nbsp;assume&nbsp;it's&nbsp;logged&nbsp;out.
<a name="line4568"></a><div class="linenumber">4568</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;easyrtcid&nbsp;the&nbsp;easyrtcId&nbsp;of&nbsp;the&nbsp;peer.
<a name="line4569"></a><div class="linenumber">4569</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4570"></a><div class="linenumber">4570</div><div style="width:2em;display:inline-block"></div>this.isPeerInAnyRoom&nbsp;=&nbsp;function(easyrtcid)&nbsp;{
<a name="line4571"></a><div class="linenumber">4571</div><div style="width:4em;display:inline-block"></div>return&nbsp;isPeerInAnyRoom(easyrtcid);
<a name="line4572"></a><div class="linenumber">4572</div><div style="width:2em;display:inline-block"></div>};
<a name="line4573"></a><div class="linenumber">4573</div>
<a name="line4574"></a><div class="linenumber">4574</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4575"></a><div class="linenumber">4575</div><div style="width:2em;display:inline-block"></div>function&nbsp;processLostPeers(peersInRoom)&nbsp;{
<a name="line4576"></a><div class="linenumber">4576</div><div style="width:4em;display:inline-block"></div>var&nbsp;id;
<a name="line4577"></a><div class="linenumber">4577</div><div style="width:4em;display:inline-block"></div>//
<a name="line4578"></a><div class="linenumber">4578</div><div style="width:4em;display:inline-block"></div>//&nbsp;check&nbsp;to&nbsp;see&nbsp;the&nbsp;person&nbsp;is&nbsp;still&nbsp;in&nbsp;at&nbsp;least&nbsp;one&nbsp;room.&nbsp;If&nbsp;not,&nbsp;we'll&nbsp;hangup
<a name="line4579"></a><div class="linenumber">4579</div><div style="width:4em;display:inline-block"></div>//&nbsp;on&nbsp;them.&nbsp;This&nbsp;isn't&nbsp;the&nbsp;correct&nbsp;behavior,&nbsp;but&nbsp;it's&nbsp;the&nbsp;best&nbsp;we&nbsp;can&nbsp;do&nbsp;without
<a name="line4580"></a><div class="linenumber">4580</div><div style="width:4em;display:inline-block"></div>//&nbsp;changes&nbsp;to&nbsp;the&nbsp;server.
<a name="line4581"></a><div class="linenumber">4581</div><div style="width:4em;display:inline-block"></div>//
<a name="line4582"></a><div class="linenumber">4582</div><div style="width:4em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;peerConns)&nbsp;{
<a name="line4583"></a><div class="linenumber">4583</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns.hasOwnProperty(id)&nbsp;&amp;&amp;
<a name="line4584"></a><div class="linenumber">4584</div><div style="width:10em;display:inline-block"></div>typeof&nbsp;peersInRoom[id]&nbsp;===&nbsp;'undefined')&nbsp;{
<a name="line4585"></a><div class="linenumber">4585</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!isPeerInAnyRoom(id))&nbsp;{
<a name="line4586"></a><div class="linenumber">4586</div><div style="width:10em;display:inline-block"></div>if&nbsp;(peerConns[id].pc&nbsp;||&nbsp;peerConns[id].isInitiator)&nbsp;{
<a name="line4587"></a><div class="linenumber">4587</div><div style="width:12em;display:inline-block"></div>onRemoteHangup(id);
<a name="line4588"></a><div class="linenumber">4588</div><div style="width:10em;display:inline-block"></div>}
<a name="line4589"></a><div class="linenumber">4589</div><div style="width:10em;display:inline-block"></div>delete&nbsp;offersPending[id];
<a name="line4590"></a><div class="linenumber">4590</div><div style="width:10em;display:inline-block"></div>delete&nbsp;acceptancePending[id];
<a name="line4591"></a><div class="linenumber">4591</div><div style="width:10em;display:inline-block"></div>clearQueuedMessages(id);
<a name="line4592"></a><div class="linenumber">4592</div><div style="width:8em;display:inline-block"></div>}
<a name="line4593"></a><div class="linenumber">4593</div><div style="width:6em;display:inline-block"></div>}
<a name="line4594"></a><div class="linenumber">4594</div><div style="width:4em;display:inline-block"></div>}
<a name="line4595"></a><div class="linenumber">4595</div>
<a name="line4596"></a><div class="linenumber">4596</div><div style="width:4em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;offersPending)&nbsp;{
<a name="line4597"></a><div class="linenumber">4597</div><div style="width:6em;display:inline-block"></div>if&nbsp;(offersPending.hasOwnProperty(id)&nbsp;&amp;&amp;&nbsp;!isPeerInAnyRoom(id))&nbsp;{
<a name="line4598"></a><div class="linenumber">4598</div><div style="width:8em;display:inline-block"></div>onRemoteHangup(id);
<a name="line4599"></a><div class="linenumber">4599</div><div style="width:8em;display:inline-block"></div>clearQueuedMessages(id);
<a name="line4600"></a><div class="linenumber">4600</div><div style="width:8em;display:inline-block"></div>delete&nbsp;offersPending[id];
<a name="line4601"></a><div class="linenumber">4601</div><div style="width:8em;display:inline-block"></div>delete&nbsp;acceptancePending[id];
<a name="line4602"></a><div class="linenumber">4602</div><div style="width:6em;display:inline-block"></div>}
<a name="line4603"></a><div class="linenumber">4603</div><div style="width:4em;display:inline-block"></div>}
<a name="line4604"></a><div class="linenumber">4604</div>
<a name="line4605"></a><div class="linenumber">4605</div><div style="width:4em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;acceptancePending)&nbsp;{
<a name="line4606"></a><div class="linenumber">4606</div><div style="width:6em;display:inline-block"></div>if&nbsp;(acceptancePending.hasOwnProperty(id)&nbsp;&amp;&amp;&nbsp;!isPeerInAnyRoom(id))&nbsp;{
<a name="line4607"></a><div class="linenumber">4607</div><div style="width:8em;display:inline-block"></div>onRemoteHangup(id);
<a name="line4608"></a><div class="linenumber">4608</div><div style="width:8em;display:inline-block"></div>clearQueuedMessages(id);
<a name="line4609"></a><div class="linenumber">4609</div><div style="width:8em;display:inline-block"></div>delete&nbsp;acceptancePending[id];
<a name="line4610"></a><div class="linenumber">4610</div><div style="width:6em;display:inline-block"></div>}
<a name="line4611"></a><div class="linenumber">4611</div><div style="width:4em;display:inline-block"></div>}
<a name="line4612"></a><div class="linenumber">4612</div><div style="width:2em;display:inline-block"></div>}
<a name="line4613"></a><div class="linenumber">4613</div>
<a name="line4614"></a><div class="linenumber">4614</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4615"></a><div class="linenumber">4615</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;idea&nbsp;of&nbsp;aggregating&nbsp;timers&nbsp;is&nbsp;that&nbsp;there&nbsp;are&nbsp;events&nbsp;that&nbsp;convey&nbsp;state&nbsp;and&nbsp;these&nbsp;can&nbsp;fire&nbsp;more&nbsp;frequently
<a name="line4616"></a><div class="linenumber">4616</div><div style="width:2em;display:inline-block"></div>*&nbsp;than&nbsp;desired.&nbsp;Aggregating&nbsp;timers&nbsp;allow&nbsp;a&nbsp;bunch&nbsp;of&nbsp;events&nbsp;to&nbsp;be&nbsp;collapsed&nbsp;into&nbsp;one&nbsp;by&nbsp;only&nbsp;firing&nbsp;the&nbsp;last
<a name="line4617"></a><div class="linenumber">4617</div><div style="width:2em;display:inline-block"></div>*&nbsp;event.
<a name="line4618"></a><div class="linenumber">4618</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line4619"></a><div class="linenumber">4619</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4620"></a><div class="linenumber">4620</div><div style="width:2em;display:inline-block"></div>var&nbsp;aggregatingTimers&nbsp;=&nbsp;{};
<a name="line4621"></a><div class="linenumber">4621</div>
<a name="line4622"></a><div class="linenumber">4622</div><div style="width:2em;display:inline-block"></div>/**
<a name="line4623"></a><div class="linenumber">4623</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;sets&nbsp;a&nbsp;timeout&nbsp;for&nbsp;a&nbsp;function&nbsp;to&nbsp;be&nbsp;called&nbsp;with&nbsp;the&nbsp;feature&nbsp;that&nbsp;if&nbsp;another
<a name="line4624"></a><div class="linenumber">4624</div><div style="width:2em;display:inline-block"></div>*&nbsp;invocation&nbsp;comes&nbsp;along&nbsp;within&nbsp;a&nbsp;particular&nbsp;interval&nbsp;(with&nbsp;the&nbsp;same&nbsp;key),&nbsp;the&nbsp;second&nbsp;invocation
<a name="line4625"></a><div class="linenumber">4625</div><div style="width:2em;display:inline-block"></div>*&nbsp;replaces&nbsp;the&nbsp;first.&nbsp;To&nbsp;prevent&nbsp;a&nbsp;continuous&nbsp;stream&nbsp;of&nbsp;events&nbsp;from&nbsp;preventing&nbsp;a&nbsp;callback&nbsp;from&nbsp;ever
<a name="line4626"></a><div class="linenumber">4626</div><div style="width:2em;display:inline-block"></div>*&nbsp;firing,&nbsp;we'll&nbsp;collapse&nbsp;no&nbsp;more&nbsp;than&nbsp;20&nbsp;events.
<a name="line4627"></a><div class="linenumber">4627</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;key&nbsp;A&nbsp;key&nbsp;used&nbsp;to&nbsp;identify&nbsp;callbacks&nbsp;that&nbsp;should&nbsp;be&nbsp;aggregated.
<a name="line4628"></a><div class="linenumber">4628</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callback&nbsp;The&nbsp;callback&nbsp;to&nbsp;invoke.
<a name="line4629"></a><div class="linenumber">4629</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Number}&nbsp;period&nbsp;The&nbsp;aggregating&nbsp;period&nbsp;in&nbsp;milliseconds.
<a name="line4630"></a><div class="linenumber">4630</div><div style="width:2em;display:inline-block"></div>*&nbsp;@private
<a name="line4631"></a><div class="linenumber">4631</div><div style="width:2em;display:inline-block"></div>*/
<a name="line4632"></a><div class="linenumber">4632</div><div style="width:2em;display:inline-block"></div>function&nbsp;addAggregatingTimer(key,&nbsp;callback,&nbsp;period)&nbsp;{
<a name="line4633"></a><div class="linenumber">4633</div><div style="width:4em;display:inline-block"></div>if(&nbsp;!period)&nbsp;{
<a name="line4634"></a><div class="linenumber">4634</div><div style="width:6em;display:inline-block"></div>period&nbsp;=&nbsp;100;&nbsp;//&nbsp;0.1&nbsp;second
<a name="line4635"></a><div class="linenumber">4635</div><div style="width:4em;display:inline-block"></div>}
<a name="line4636"></a><div class="linenumber">4636</div><div style="width:4em;display:inline-block"></div>var&nbsp;counter&nbsp;=&nbsp;0;
<a name="line4637"></a><div class="linenumber">4637</div><div style="width:4em;display:inline-block"></div>if(&nbsp;aggregatingTimers[key])&nbsp;{
<a name="line4638"></a><div class="linenumber">4638</div><div style="width:6em;display:inline-block"></div>clearTimeout(aggregatingTimers[key].timer);
<a name="line4639"></a><div class="linenumber">4639</div><div style="width:6em;display:inline-block"></div>counter&nbsp;=&nbsp;aggregatingTimers[key].counter;
<a name="line4640"></a><div class="linenumber">4640</div><div style="width:4em;display:inline-block"></div>}
<a name="line4641"></a><div class="linenumber">4641</div><div style="width:4em;display:inline-block"></div>if(&nbsp;counter&nbsp;&gt;&nbsp;20)&nbsp;{
<a name="line4642"></a><div class="linenumber">4642</div><div style="width:6em;display:inline-block"></div>delete&nbsp;aggregatingTimers[key];
<a name="line4643"></a><div class="linenumber">4643</div><div style="width:6em;display:inline-block"></div>callback();
<a name="line4644"></a><div class="linenumber">4644</div><div style="width:4em;display:inline-block"></div>}
<a name="line4645"></a><div class="linenumber">4645</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4646"></a><div class="linenumber">4646</div><div style="width:6em;display:inline-block"></div>aggregatingTimers[key]&nbsp;=&nbsp;{counter:&nbsp;counter&nbsp;+1};
<a name="line4647"></a><div class="linenumber">4647</div><div style="width:6em;display:inline-block"></div>aggregatingTimers[key].timer&nbsp;=&nbsp;setTimeout(function&nbsp;()&nbsp;{
<a name="line4648"></a><div class="linenumber">4648</div><div style="width:8em;display:inline-block"></div>delete&nbsp;aggregatingTimers[key];
<a name="line4649"></a><div class="linenumber">4649</div><div style="width:8em;display:inline-block"></div>callback();
<a name="line4650"></a><div class="linenumber">4650</div><div style="width:6em;display:inline-block"></div>},&nbsp;period);
<a name="line4651"></a><div class="linenumber">4651</div><div style="width:4em;display:inline-block"></div>}
<a name="line4652"></a><div class="linenumber">4652</div><div style="width:2em;display:inline-block"></div>}
<a name="line4653"></a><div class="linenumber">4653</div>
<a name="line4654"></a><div class="linenumber">4654</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4655"></a><div class="linenumber">4655</div><div style="width:2em;display:inline-block"></div>//
<a name="line4656"></a><div class="linenumber">4656</div><div style="width:2em;display:inline-block"></div>//&nbsp;this&nbsp;function&nbsp;gets&nbsp;called&nbsp;for&nbsp;each&nbsp;room&nbsp;when&nbsp;there&nbsp;is&nbsp;a&nbsp;room&nbsp;update.
<a name="line4657"></a><div class="linenumber">4657</div><div style="width:2em;display:inline-block"></div>//
<a name="line4658"></a><div class="linenumber">4658</div><div style="width:2em;display:inline-block"></div>function&nbsp;processOccupantList(roomName,&nbsp;occupantList)&nbsp;{
<a name="line4659"></a><div class="linenumber">4659</div><div style="width:4em;display:inline-block"></div>var&nbsp;myInfo&nbsp;=&nbsp;null;
<a name="line4660"></a><div class="linenumber">4660</div><div style="width:4em;display:inline-block"></div>var&nbsp;reducedList&nbsp;=&nbsp;{};
<a name="line4661"></a><div class="linenumber">4661</div>
<a name="line4662"></a><div class="linenumber">4662</div><div style="width:4em;display:inline-block"></div>var&nbsp;id;
<a name="line4663"></a><div class="linenumber">4663</div><div style="width:4em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;occupantList)&nbsp;{
<a name="line4664"></a><div class="linenumber">4664</div><div style="width:6em;display:inline-block"></div>if&nbsp;(occupantList.hasOwnProperty(id))&nbsp;{
<a name="line4665"></a><div class="linenumber">4665</div><div style="width:8em;display:inline-block"></div>if&nbsp;(id&nbsp;===&nbsp;self.myEasyrtcid)&nbsp;{
<a name="line4666"></a><div class="linenumber">4666</div><div style="width:10em;display:inline-block"></div>myInfo&nbsp;=&nbsp;occupantList[id];
<a name="line4667"></a><div class="linenumber">4667</div><div style="width:8em;display:inline-block"></div>}
<a name="line4668"></a><div class="linenumber">4668</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line4669"></a><div class="linenumber">4669</div><div style="width:10em;display:inline-block"></div>reducedList[id]&nbsp;=&nbsp;occupantList[id];
<a name="line4670"></a><div class="linenumber">4670</div><div style="width:8em;display:inline-block"></div>}
<a name="line4671"></a><div class="linenumber">4671</div><div style="width:6em;display:inline-block"></div>}
<a name="line4672"></a><div class="linenumber">4672</div><div style="width:4em;display:inline-block"></div>}
<a name="line4673"></a><div class="linenumber">4673</div><div style="width:4em;display:inline-block"></div>//
<a name="line4674"></a><div class="linenumber">4674</div><div style="width:4em;display:inline-block"></div>//&nbsp;processLostPeers&nbsp;detects&nbsp;peers&nbsp;that&nbsp;have&nbsp;gone&nbsp;away&nbsp;and&nbsp;performs
<a name="line4675"></a><div class="linenumber">4675</div><div style="width:4em;display:inline-block"></div>//&nbsp;house&nbsp;keeping&nbsp;accordingly.
<a name="line4676"></a><div class="linenumber">4676</div><div style="width:4em;display:inline-block"></div>//
<a name="line4677"></a><div class="linenumber">4677</div><div style="width:4em;display:inline-block"></div>processLostPeers(reducedList);
<a name="line4678"></a><div class="linenumber">4678</div><div style="width:4em;display:inline-block"></div>//
<a name="line4679"></a><div class="linenumber">4679</div><div style="width:4em;display:inline-block"></div>//
<a name="line4680"></a><div class="linenumber">4680</div><div style="width:4em;display:inline-block"></div>//
<a name="line4681"></a><div class="linenumber">4681</div><div style="width:4em;display:inline-block"></div>addAggregatingTimer("roomOccupants&amp;"&nbsp;+&nbsp;roomName,&nbsp;function(){
<a name="line4682"></a><div class="linenumber">4682</div><div style="width:6em;display:inline-block"></div>if&nbsp;(roomOccupantListener)&nbsp;{
<a name="line4683"></a><div class="linenumber">4683</div><div style="width:8em;display:inline-block"></div>roomOccupantListener(roomName,&nbsp;reducedList,&nbsp;myInfo);
<a name="line4684"></a><div class="linenumber">4684</div><div style="width:6em;display:inline-block"></div>}
<a name="line4685"></a><div class="linenumber">4685</div><div style="width:6em;display:inline-block"></div>self.emitEvent("roomOccupants",&nbsp;{roomName:roomName,&nbsp;occupants:lastLoggedInList});
<a name="line4686"></a><div class="linenumber">4686</div><div style="width:4em;display:inline-block"></div>},&nbsp;100);
<a name="line4687"></a><div class="linenumber">4687</div><div style="width:2em;display:inline-block"></div>}
<a name="line4688"></a><div class="linenumber">4688</div>
<a name="line4689"></a><div class="linenumber">4689</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4690"></a><div class="linenumber">4690</div><div style="width:2em;display:inline-block"></div>function&nbsp;onChannelMsg(msg,&nbsp;ackAcceptorFunc)&nbsp;{
<a name="line4691"></a><div class="linenumber">4691</div>
<a name="line4692"></a><div class="linenumber">4692</div><div style="width:4em;display:inline-block"></div>var&nbsp;targeting&nbsp;=&nbsp;{};
<a name="line4693"></a><div class="linenumber">4693</div><div style="width:4em;display:inline-block"></div>if&nbsp;(ackAcceptorFunc)&nbsp;{
<a name="line4694"></a><div class="linenumber">4694</div><div style="width:6em;display:inline-block"></div>ackAcceptorFunc(self.ackMessage);
<a name="line4695"></a><div class="linenumber">4695</div><div style="width:4em;display:inline-block"></div>}
<a name="line4696"></a><div class="linenumber">4696</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msg.targetEasyrtcid)&nbsp;{
<a name="line4697"></a><div class="linenumber">4697</div><div style="width:6em;display:inline-block"></div>targeting.targetEasyrtcid&nbsp;=&nbsp;msg.targetEasyrtcid;
<a name="line4698"></a><div class="linenumber">4698</div><div style="width:4em;display:inline-block"></div>}
<a name="line4699"></a><div class="linenumber">4699</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msg.targetRoom)&nbsp;{
<a name="line4700"></a><div class="linenumber">4700</div><div style="width:6em;display:inline-block"></div>targeting.targetRoom&nbsp;=&nbsp;msg.targetRoom;
<a name="line4701"></a><div class="linenumber">4701</div><div style="width:4em;display:inline-block"></div>}
<a name="line4702"></a><div class="linenumber">4702</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msg.targetGroup)&nbsp;{
<a name="line4703"></a><div class="linenumber">4703</div><div style="width:6em;display:inline-block"></div>targeting.targetGroup&nbsp;=&nbsp;msg.targetGroup;
<a name="line4704"></a><div class="linenumber">4704</div><div style="width:4em;display:inline-block"></div>}
<a name="line4705"></a><div class="linenumber">4705</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msg.senderEasyrtcid)&nbsp;{
<a name="line4706"></a><div class="linenumber">4706</div><div style="width:6em;display:inline-block"></div>self.receivePeerDistribute(msg.senderEasyrtcid,&nbsp;msg,&nbsp;targeting);
<a name="line4707"></a><div class="linenumber">4707</div><div style="width:4em;display:inline-block"></div>}
<a name="line4708"></a><div class="linenumber">4708</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line4709"></a><div class="linenumber">4709</div><div style="width:6em;display:inline-block"></div>if&nbsp;(receiveServerCB)&nbsp;{
<a name="line4710"></a><div class="linenumber">4710</div><div style="width:8em;display:inline-block"></div>receiveServerCB(msg.msgType,&nbsp;msg.msgData,&nbsp;targeting);
<a name="line4711"></a><div class="linenumber">4711</div><div style="width:6em;display:inline-block"></div>}
<a name="line4712"></a><div class="linenumber">4712</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line4713"></a><div class="linenumber">4713</div><div style="width:8em;display:inline-block"></div>logDebug("Unhandled&nbsp;server&nbsp;message&nbsp;"&nbsp;+&nbsp;JSON.stringify(msg));
<a name="line4714"></a><div class="linenumber">4714</div><div style="width:6em;display:inline-block"></div>}
<a name="line4715"></a><div class="linenumber">4715</div><div style="width:4em;display:inline-block"></div>}
<a name="line4716"></a><div class="linenumber">4716</div><div style="width:2em;display:inline-block"></div>}
<a name="line4717"></a><div class="linenumber">4717</div>
<a name="line4718"></a><div class="linenumber">4718</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4719"></a><div class="linenumber">4719</div><div style="width:2em;display:inline-block"></div>function&nbsp;processUrl(url)&nbsp;{
<a name="line4720"></a><div class="linenumber">4720</div><div style="width:4em;display:inline-block"></div>var&nbsp;ipAddress;
<a name="line4721"></a><div class="linenumber">4721</div><div style="width:4em;display:inline-block"></div>if&nbsp;(url.indexOf('turn:')&nbsp;===&nbsp;0&nbsp;||&nbsp;url.indexOf('turns:')&nbsp;===&nbsp;0)&nbsp;{
<a name="line4722"></a><div class="linenumber">4722</div><div style="width:6em;display:inline-block"></div>ipAddress&nbsp;=&nbsp;url.split(/[@:&amp;]/g)[1];
<a name="line4723"></a><div class="linenumber">4723</div><div style="width:6em;display:inline-block"></div>self._turnServers[ipAddress]&nbsp;=&nbsp;true;
<a name="line4724"></a><div class="linenumber">4724</div><div style="width:4em;display:inline-block"></div>}&nbsp;else&nbsp;if&nbsp;(url.indexOf('stun:')&nbsp;===&nbsp;0&nbsp;||&nbsp;url.indexOf('stuns:')&nbsp;===&nbsp;0)&nbsp;{
<a name="line4725"></a><div class="linenumber">4725</div><div style="width:6em;display:inline-block"></div>ipAddress&nbsp;=&nbsp;url.split(/[@:&amp;]/g)[1];
<a name="line4726"></a><div class="linenumber">4726</div><div style="width:6em;display:inline-block"></div>self._stunServers[ipAddress]&nbsp;=&nbsp;true;
<a name="line4727"></a><div class="linenumber">4727</div><div style="width:4em;display:inline-block"></div>}
<a name="line4728"></a><div class="linenumber">4728</div><div style="width:2em;display:inline-block"></div>}
<a name="line4729"></a><div class="linenumber">4729</div>
<a name="line4730"></a><div class="linenumber">4730</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4731"></a><div class="linenumber">4731</div><div style="width:2em;display:inline-block"></div>function&nbsp;processIceConfig(iceConfig)&nbsp;{
<a name="line4732"></a><div class="linenumber">4732</div>
<a name="line4733"></a><div class="linenumber">4733</div><div style="width:4em;display:inline-block"></div>var&nbsp;i,&nbsp;j,&nbsp;item;
<a name="line4734"></a><div class="linenumber">4734</div>
<a name="line4735"></a><div class="linenumber">4735</div><div style="width:4em;display:inline-block"></div>pc_config&nbsp;=&nbsp;{
<a name="line4736"></a><div class="linenumber">4736</div><div style="width:6em;display:inline-block"></div>iceServers:&nbsp;[]
<a name="line4737"></a><div class="linenumber">4737</div><div style="width:4em;display:inline-block"></div>};
<a name="line4738"></a><div class="linenumber">4738</div>
<a name="line4739"></a><div class="linenumber">4739</div><div style="width:4em;display:inline-block"></div>self._turnServers&nbsp;=&nbsp;{};
<a name="line4740"></a><div class="linenumber">4740</div><div style="width:4em;display:inline-block"></div>self._stunServers&nbsp;=&nbsp;{};
<a name="line4741"></a><div class="linenumber">4741</div>
<a name="line4742"></a><div class="linenumber">4742</div><div style="width:4em;display:inline-block"></div>if&nbsp;(
<a name="line4743"></a><div class="linenumber">4743</div><div style="width:6em;display:inline-block"></div>!iceConfig&nbsp;||
<a name="line4744"></a><div class="linenumber">4744</div><div style="width:8em;display:inline-block"></div>!iceConfig.iceServers&nbsp;||
<a name="line4745"></a><div class="linenumber">4745</div><div style="width:10em;display:inline-block"></div>typeof&nbsp;iceConfig.iceServers.length&nbsp;===&nbsp;"undefined"
<a name="line4746"></a><div class="linenumber">4746</div><div style="width:4em;display:inline-block"></div>)&nbsp;{
<a name="line4747"></a><div class="linenumber">4747</div><div style="width:6em;display:inline-block"></div>self.showError(
<a name="line4748"></a><div class="linenumber">4748</div><div style="width:8em;display:inline-block"></div>self.errCodes.DEVELOPER_ERR,
<a name="line4749"></a><div class="linenumber">4749</div><div style="width:8em;display:inline-block"></div>"iceConfig&nbsp;received&nbsp;from&nbsp;server&nbsp;didn't&nbsp;have&nbsp;an&nbsp;array&nbsp;called&nbsp;iceServers,&nbsp;ignoring&nbsp;it"
<a name="line4750"></a><div class="linenumber">4750</div><div style="width:6em;display:inline-block"></div>);
<a name="line4751"></a><div class="linenumber">4751</div><div style="width:4em;display:inline-block"></div>}&nbsp;else&nbsp;{
<a name="line4752"></a><div class="linenumber">4752</div><div style="width:6em;display:inline-block"></div>pc_config&nbsp;=&nbsp;{
<a name="line4753"></a><div class="linenumber">4753</div><div style="width:8em;display:inline-block"></div>iceServers:&nbsp;iceConfig.iceServers
<a name="line4754"></a><div class="linenumber">4754</div><div style="width:6em;display:inline-block"></div>};
<a name="line4755"></a><div class="linenumber">4755</div><div style="width:4em;display:inline-block"></div>}
<a name="line4756"></a><div class="linenumber">4756</div>
<a name="line4757"></a><div class="linenumber">4757</div><div style="width:4em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;iceConfig.iceServers.length;&nbsp;i++)&nbsp;{
<a name="line4758"></a><div class="linenumber">4758</div><div style="width:6em;display:inline-block"></div>item&nbsp;=&nbsp;iceConfig.iceServers[i];
<a name="line4759"></a><div class="linenumber">4759</div><div style="width:6em;display:inline-block"></div>if(&nbsp;item.urls&nbsp;&amp;&amp;&nbsp;item.urls.length&nbsp;)&nbsp;{
<a name="line4760"></a><div class="linenumber">4760</div><div style="width:7em;display:inline-block"></div>for(&nbsp;j&nbsp;=&nbsp;0;&nbsp;j&nbsp;&lt;&nbsp;item.urls.length;&nbsp;j++&nbsp;)&nbsp;{
<a name="line4761"></a><div class="linenumber">4761</div><div style="width:9em;display:inline-block"></div>processUrl(item.urls[j]);
<a name="line4762"></a><div class="linenumber">4762</div><div style="width:7em;display:inline-block"></div>}
<a name="line4763"></a><div class="linenumber">4763</div><div style="width:6em;display:inline-block"></div>}
<a name="line4764"></a><div class="linenumber">4764</div><div style="width:6em;display:inline-block"></div>else&nbsp;if(&nbsp;item.url&nbsp;)&nbsp;{
<a name="line4765"></a><div class="linenumber">4765</div><div style="width:7em;display:inline-block"></div>processUrl(item.url);
<a name="line4766"></a><div class="linenumber">4766</div><div style="width:6em;display:inline-block"></div>}
<a name="line4767"></a><div class="linenumber">4767</div><div style="width:4em;display:inline-block"></div>}
<a name="line4768"></a><div class="linenumber">4768</div><div style="width:2em;display:inline-block"></div>}
<a name="line4769"></a><div class="linenumber">4769</div>
<a name="line4770"></a><div class="linenumber">4770</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4771"></a><div class="linenumber">4771</div><div style="width:2em;display:inline-block"></div>function&nbsp;processSessionData(sessionData)&nbsp;{
<a name="line4772"></a><div class="linenumber">4772</div><div style="width:4em;display:inline-block"></div>if&nbsp;(sessionData)&nbsp;{
<a name="line4773"></a><div class="linenumber">4773</div><div style="width:6em;display:inline-block"></div>if&nbsp;(sessionData.easyrtcsid)&nbsp;{
<a name="line4774"></a><div class="linenumber">4774</div><div style="width:8em;display:inline-block"></div>self.easyrtcsid&nbsp;=&nbsp;sessionData.easyrtcsid;
<a name="line4775"></a><div class="linenumber">4775</div><div style="width:6em;display:inline-block"></div>}
<a name="line4776"></a><div class="linenumber">4776</div><div style="width:6em;display:inline-block"></div>if&nbsp;(sessionData.field)&nbsp;{
<a name="line4777"></a><div class="linenumber">4777</div><div style="width:8em;display:inline-block"></div>sessionFields&nbsp;=&nbsp;sessionData.field;
<a name="line4778"></a><div class="linenumber">4778</div><div style="width:6em;display:inline-block"></div>}
<a name="line4779"></a><div class="linenumber">4779</div><div style="width:4em;display:inline-block"></div>}
<a name="line4780"></a><div class="linenumber">4780</div><div style="width:2em;display:inline-block"></div>}
<a name="line4781"></a><div class="linenumber">4781</div>
<a name="line4782"></a><div class="linenumber">4782</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4783"></a><div class="linenumber">4783</div><div style="width:2em;display:inline-block"></div>function&nbsp;processRoomData(roomData)&nbsp;{
<a name="line4784"></a><div class="linenumber">4784</div><div style="width:4em;display:inline-block"></div>self.roomData&nbsp;=&nbsp;roomData;
<a name="line4785"></a><div class="linenumber">4785</div>
<a name="line4786"></a><div class="linenumber">4786</div><div style="width:4em;display:inline-block"></div>var&nbsp;k,&nbsp;roomName,
<a name="line4787"></a><div class="linenumber">4787</div><div style="width:6em;display:inline-block"></div>stuffToRemove,&nbsp;stuffToAdd,
<a name="line4788"></a><div class="linenumber">4788</div><div style="width:6em;display:inline-block"></div>id,&nbsp;removeId;
<a name="line4789"></a><div class="linenumber">4789</div>
<a name="line4790"></a><div class="linenumber">4790</div><div style="width:4em;display:inline-block"></div>for&nbsp;(roomName&nbsp;in&nbsp;self.roomData)&nbsp;{
<a name="line4791"></a><div class="linenumber">4791</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!self.roomData.hasOwnProperty(roomName))&nbsp;{
<a name="line4792"></a><div class="linenumber">4792</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line4793"></a><div class="linenumber">4793</div><div style="width:6em;display:inline-block"></div>}
<a name="line4794"></a><div class="linenumber">4794</div><div style="width:6em;display:inline-block"></div>if&nbsp;(roomData[roomName].roomStatus&nbsp;===&nbsp;"join")&nbsp;{
<a name="line4795"></a><div class="linenumber">4795</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!(self.roomJoin[roomName]))&nbsp;{
<a name="line4796"></a><div class="linenumber">4796</div><div style="width:10em;display:inline-block"></div>self.roomJoin[roomName]&nbsp;=&nbsp;roomData[roomName];
<a name="line4797"></a><div class="linenumber">4797</div><div style="width:8em;display:inline-block"></div>}
<a name="line4798"></a><div class="linenumber">4798</div><div style="width:8em;display:inline-block"></div>var&nbsp;mediaIds&nbsp;=&nbsp;buildMediaIds();
<a name="line4799"></a><div class="linenumber">4799</div><div style="width:8em;display:inline-block"></div>if&nbsp;(mediaIds&nbsp;!==&nbsp;{})&nbsp;{
<a name="line4800"></a><div class="linenumber">4800</div><div style="width:10em;display:inline-block"></div>self.setRoomApiField(roomName,&nbsp;"mediaIds",&nbsp;mediaIds);
<a name="line4801"></a><div class="linenumber">4801</div><div style="width:8em;display:inline-block"></div>}
<a name="line4802"></a><div class="linenumber">4802</div><div style="width:6em;display:inline-block"></div>}
<a name="line4803"></a><div class="linenumber">4803</div><div style="width:6em;display:inline-block"></div>else&nbsp;if&nbsp;(roomData[roomName].roomStatus&nbsp;===&nbsp;"leave")&nbsp;{
<a name="line4804"></a><div class="linenumber">4804</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.roomEntryListener)&nbsp;{
<a name="line4805"></a><div class="linenumber">4805</div><div style="width:10em;display:inline-block"></div>self.roomEntryListener(false,&nbsp;roomName);
<a name="line4806"></a><div class="linenumber">4806</div><div style="width:8em;display:inline-block"></div>}
<a name="line4807"></a><div class="linenumber">4807</div><div style="width:8em;display:inline-block"></div>delete&nbsp;self.roomJoin[roomName];
<a name="line4808"></a><div class="linenumber">4808</div><div style="width:8em;display:inline-block"></div>delete&nbsp;lastLoggedInList[roomName];
<a name="line4809"></a><div class="linenumber">4809</div><div style="width:8em;display:inline-block"></div>continue;
<a name="line4810"></a><div class="linenumber">4810</div><div style="width:6em;display:inline-block"></div>}
<a name="line4811"></a><div class="linenumber">4811</div>
<a name="line4812"></a><div class="linenumber">4812</div><div style="width:6em;display:inline-block"></div>if&nbsp;(roomData[roomName].clientList)&nbsp;{
<a name="line4813"></a><div class="linenumber">4813</div><div style="width:8em;display:inline-block"></div>lastLoggedInList[roomName]&nbsp;=&nbsp;roomData[roomName].clientList;
<a name="line4814"></a><div class="linenumber">4814</div><div style="width:6em;display:inline-block"></div>}
<a name="line4815"></a><div class="linenumber">4815</div><div style="width:6em;display:inline-block"></div>else&nbsp;if&nbsp;(roomData[roomName].clientListDelta)&nbsp;{
<a name="line4816"></a><div class="linenumber">4816</div><div style="width:8em;display:inline-block"></div>stuffToAdd&nbsp;=&nbsp;roomData[roomName].clientListDelta.updateClient;
<a name="line4817"></a><div class="linenumber">4817</div><div style="width:8em;display:inline-block"></div>if&nbsp;(stuffToAdd)&nbsp;{
<a name="line4818"></a><div class="linenumber">4818</div><div style="width:10em;display:inline-block"></div>for&nbsp;(id&nbsp;in&nbsp;stuffToAdd)&nbsp;{
<a name="line4819"></a><div class="linenumber">4819</div><div style="width:12em;display:inline-block"></div>if&nbsp;(!stuffToAdd.hasOwnProperty(id))&nbsp;{
<a name="line4820"></a><div class="linenumber">4820</div><div style="width:14em;display:inline-block"></div>continue;
<a name="line4821"></a><div class="linenumber">4821</div><div style="width:12em;display:inline-block"></div>}
<a name="line4822"></a><div class="linenumber">4822</div><div style="width:12em;display:inline-block"></div>if&nbsp;(!lastLoggedInList[roomName])&nbsp;{
<a name="line4823"></a><div class="linenumber">4823</div><div style="width:14em;display:inline-block"></div>lastLoggedInList[roomName]&nbsp;=&nbsp;[];
<a name="line4824"></a><div class="linenumber">4824</div><div style="width:12em;display:inline-block"></div>}
<a name="line4825"></a><div class="linenumber">4825</div><div style="width:12em;display:inline-block"></div>if(&nbsp;!lastLoggedInList[roomName][id]&nbsp;)&nbsp;{
<a name="line4826"></a><div class="linenumber">4826</div><div style="width:13em;display:inline-block"></div>lastLoggedInList[roomName][id]&nbsp;=&nbsp;stuffToAdd[id];
<a name="line4827"></a><div class="linenumber">4827</div><div style="width:12em;display:inline-block"></div>}
<a name="line4828"></a><div class="linenumber">4828</div><div style="width:12em;display:inline-block"></div>for(&nbsp;k&nbsp;in&nbsp;stuffToAdd[id]&nbsp;)&nbsp;{
<a name="line4829"></a><div class="linenumber">4829</div><div style="width:13em;display:inline-block"></div>if(&nbsp;k&nbsp;===&nbsp;"apiField"&nbsp;||&nbsp;k&nbsp;===&nbsp;"presence")&nbsp;{
<a name="line4830"></a><div class="linenumber">4830</div><div style="width:15em;display:inline-block"></div>lastLoggedInList[roomName][id][k]&nbsp;=&nbsp;stuffToAdd[id][k];
<a name="line4831"></a><div class="linenumber">4831</div><div style="width:13em;display:inline-block"></div>}
<a name="line4832"></a><div class="linenumber">4832</div><div style="width:12em;display:inline-block"></div>}
<a name="line4833"></a><div class="linenumber">4833</div><div style="width:10em;display:inline-block"></div>}
<a name="line4834"></a><div class="linenumber">4834</div><div style="width:8em;display:inline-block"></div>}
<a name="line4835"></a><div class="linenumber">4835</div><div style="width:8em;display:inline-block"></div>stuffToRemove&nbsp;=&nbsp;roomData[roomName].clientListDelta.removeClient;
<a name="line4836"></a><div class="linenumber">4836</div><div style="width:8em;display:inline-block"></div>if&nbsp;(stuffToRemove&nbsp;&amp;&amp;&nbsp;lastLoggedInList[roomName])&nbsp;{
<a name="line4837"></a><div class="linenumber">4837</div><div style="width:10em;display:inline-block"></div>for&nbsp;(removeId&nbsp;in&nbsp;stuffToRemove)&nbsp;{
<a name="line4838"></a><div class="linenumber">4838</div><div style="width:12em;display:inline-block"></div>if&nbsp;(stuffToRemove.hasOwnProperty(removeId))&nbsp;{
<a name="line4839"></a><div class="linenumber">4839</div><div style="width:14em;display:inline-block"></div>delete&nbsp;lastLoggedInList[roomName][removeId];
<a name="line4840"></a><div class="linenumber">4840</div><div style="width:12em;display:inline-block"></div>}
<a name="line4841"></a><div class="linenumber">4841</div><div style="width:10em;display:inline-block"></div>}
<a name="line4842"></a><div class="linenumber">4842</div><div style="width:8em;display:inline-block"></div>}
<a name="line4843"></a><div class="linenumber">4843</div><div style="width:6em;display:inline-block"></div>}
<a name="line4844"></a><div class="linenumber">4844</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.roomJoin[roomName]&nbsp;&amp;&amp;&nbsp;roomData[roomName].field)&nbsp;{
<a name="line4845"></a><div class="linenumber">4845</div><div style="width:8em;display:inline-block"></div>fields.rooms[roomName]&nbsp;=&nbsp;roomData[roomName].field;
<a name="line4846"></a><div class="linenumber">4846</div><div style="width:6em;display:inline-block"></div>}
<a name="line4847"></a><div class="linenumber">4847</div><div style="width:6em;display:inline-block"></div>if&nbsp;(roomData[roomName].roomStatus&nbsp;===&nbsp;"join")&nbsp;{
<a name="line4848"></a><div class="linenumber">4848</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.roomEntryListener)&nbsp;{
<a name="line4849"></a><div class="linenumber">4849</div><div style="width:10em;display:inline-block"></div>self.roomEntryListener(true,&nbsp;roomName);
<a name="line4850"></a><div class="linenumber">4850</div><div style="width:8em;display:inline-block"></div>}
<a name="line4851"></a><div class="linenumber">4851</div><div style="width:6em;display:inline-block"></div>}
<a name="line4852"></a><div class="linenumber">4852</div><div style="width:6em;display:inline-block"></div>processOccupantList(roomName,&nbsp;lastLoggedInList[roomName]);
<a name="line4853"></a><div class="linenumber">4853</div><div style="width:4em;display:inline-block"></div>}
<a name="line4854"></a><div class="linenumber">4854</div><div style="width:4em;display:inline-block"></div>self.emitEvent("roomOccupant",&nbsp;lastLoggedInList);
<a name="line4855"></a><div class="linenumber">4855</div><div style="width:2em;display:inline-block"></div>}
<a name="line4856"></a><div class="linenumber">4856</div>
<a name="line4857"></a><div class="linenumber">4857</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line4858"></a><div class="linenumber">4858</div><div style="width:2em;display:inline-block"></div>function&nbsp;onChannelCmd(msg,&nbsp;ackAcceptorFn)&nbsp;{
<a name="line4859"></a><div class="linenumber">4859</div>
<a name="line4860"></a><div class="linenumber">4860</div><div style="width:4em;display:inline-block"></div>var&nbsp;caller&nbsp;=&nbsp;msg.senderEasyrtcid;
<a name="line4861"></a><div class="linenumber">4861</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgType&nbsp;=&nbsp;msg.msgType;
<a name="line4862"></a><div class="linenumber">4862</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgData&nbsp;=&nbsp;msg.msgData;
<a name="line4863"></a><div class="linenumber">4863</div><div style="width:4em;display:inline-block"></div>var&nbsp;pc;
<a name="line4864"></a><div class="linenumber">4864</div>
<a name="line4865"></a><div class="linenumber">4865</div><div style="width:4em;display:inline-block"></div>logDebug('received&nbsp;message&nbsp;of&nbsp;type&nbsp;'&nbsp;+&nbsp;msgType);
<a name="line4866"></a><div class="linenumber">4866</div>
<a name="line4867"></a><div class="linenumber">4867</div>
<a name="line4868"></a><div class="linenumber">4868</div><div style="width:4em;display:inline-block"></div>if&nbsp;(typeof&nbsp;queuedMessages[caller]&nbsp;===&nbsp;"undefined")&nbsp;{
<a name="line4869"></a><div class="linenumber">4869</div><div style="width:6em;display:inline-block"></div>clearQueuedMessages(caller);
<a name="line4870"></a><div class="linenumber">4870</div><div style="width:4em;display:inline-block"></div>}
<a name="line4871"></a><div class="linenumber">4871</div>
<a name="line4872"></a><div class="linenumber">4872</div><div style="width:4em;display:inline-block"></div>var&nbsp;processCandidateBody&nbsp;=&nbsp;function(caller,&nbsp;msgData)&nbsp;{
<a name="line4873"></a><div class="linenumber">4873</div><div style="width:6em;display:inline-block"></div>var&nbsp;candidate&nbsp;=&nbsp;null;
<a name="line4874"></a><div class="linenumber">4874</div>
<a name="line4875"></a><div class="linenumber">4875</div><div style="width:6em;display:inline-block"></div>if(&nbsp;iceCandidateFilter&nbsp;)&nbsp;{
<a name="line4876"></a><div class="linenumber">4876</div><div style="width:7em;display:inline-block"></div>msgData&nbsp;=&nbsp;iceCandidateFilter(msgData,&nbsp;true);
<a name="line4877"></a><div class="linenumber">4877</div><div style="width:7em;display:inline-block"></div>if(&nbsp;!msgData&nbsp;)&nbsp;{
<a name="line4878"></a><div class="linenumber">4878</div><div style="width:9em;display:inline-block"></div>return;
<a name="line4879"></a><div class="linenumber">4879</div><div style="width:7em;display:inline-block"></div>}
<a name="line4880"></a><div class="linenumber">4880</div><div style="width:6em;display:inline-block"></div>}
<a name="line4881"></a><div class="linenumber">4881</div>
<a name="line4882"></a><div class="linenumber">4882</div><div style="width:6em;display:inline-block"></div>candidate&nbsp;=&nbsp;new&nbsp;RTCIceCandidate({
<a name="line4883"></a><div class="linenumber">4883</div><div style="width:8em;display:inline-block"></div>sdpMLineIndex:&nbsp;msgData.label,
<a name="line4884"></a><div class="linenumber">4884</div><div style="width:8em;display:inline-block"></div>candidate:&nbsp;msgData.candidate
<a name="line4885"></a><div class="linenumber">4885</div><div style="width:6em;display:inline-block"></div>});
<a name="line4886"></a><div class="linenumber">4886</div><div style="width:6em;display:inline-block"></div>pc&nbsp;=&nbsp;peerConns[caller].pc;
<a name="line4887"></a><div class="linenumber">4887</div>
<a name="line4888"></a><div class="linenumber">4888</div><div style="width:6em;display:inline-block"></div>function&nbsp;iceAddSuccess()&nbsp;{
<a name="line4889"></a><div class="linenumber">4889</div><div style="width:8em;display:inline-block"></div>logDebug("iceAddSuccess:&nbsp;"&nbsp;+
<a name="line4890"></a><div class="linenumber">4890</div><div style="width:10em;display:inline-block"></div>JSON.stringify(candidate));
<a name="line4891"></a><div class="linenumber">4891</div><div style="width:8em;display:inline-block"></div>processCandicate(msgData.candidate);
<a name="line4892"></a><div class="linenumber">4892</div><div style="width:6em;display:inline-block"></div>}
<a name="line4893"></a><div class="linenumber">4893</div>
<a name="line4894"></a><div class="linenumber">4894</div><div style="width:6em;display:inline-block"></div>function&nbsp;iceAddFailure(domError)&nbsp;{
<a name="line4895"></a><div class="linenumber">4895</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.ICECANDIDATE_ERR,&nbsp;"bad&nbsp;ice&nbsp;candidate&nbsp;("&nbsp;+&nbsp;domError.name&nbsp;+&nbsp;"):&nbsp;"&nbsp;+
<a name="line4896"></a><div class="linenumber">4896</div><div style="width:10em;display:inline-block"></div>JSON.stringify(candidate));
<a name="line4897"></a><div class="linenumber">4897</div><div style="width:6em;display:inline-block"></div>}
<a name="line4898"></a><div class="linenumber">4898</div>
<a name="line4899"></a><div class="linenumber">4899</div><div style="width:6em;display:inline-block"></div>pc.addIceCandidate(candidate,&nbsp;iceAddSuccess,&nbsp;iceAddFailure);
<a name="line4900"></a><div class="linenumber">4900</div><div style="width:4em;display:inline-block"></div>};
<a name="line4901"></a><div class="linenumber">4901</div>
<a name="line4902"></a><div class="linenumber">4902</div><div style="width:4em;display:inline-block"></div>var&nbsp;flushCachedCandidates&nbsp;=&nbsp;function(caller)&nbsp;{
<a name="line4903"></a><div class="linenumber">4903</div><div style="width:6em;display:inline-block"></div>var&nbsp;i;
<a name="line4904"></a><div class="linenumber">4904</div><div style="width:6em;display:inline-block"></div>if&nbsp;(queuedMessages[caller])&nbsp;{
<a name="line4905"></a><div class="linenumber">4905</div><div style="width:8em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;queuedMessages[caller].candidates.length;&nbsp;i++)&nbsp;{
<a name="line4906"></a><div class="linenumber">4906</div><div style="width:10em;display:inline-block"></div>processCandidateBody(caller,&nbsp;queuedMessages[caller].candidates[i]);
<a name="line4907"></a><div class="linenumber">4907</div><div style="width:8em;display:inline-block"></div>}
<a name="line4908"></a><div class="linenumber">4908</div><div style="width:8em;display:inline-block"></div>delete&nbsp;queuedMessages[caller];
<a name="line4909"></a><div class="linenumber">4909</div><div style="width:6em;display:inline-block"></div>}
<a name="line4910"></a><div class="linenumber">4910</div><div style="width:4em;display:inline-block"></div>};
<a name="line4911"></a><div class="linenumber">4911</div>
<a name="line4912"></a><div class="linenumber">4912</div><div style="width:4em;display:inline-block"></div>var&nbsp;processOffer&nbsp;=&nbsp;function(caller,&nbsp;msgData)&nbsp;{
<a name="line4913"></a><div class="linenumber">4913</div>
<a name="line4914"></a><div class="linenumber">4914</div><div style="width:6em;display:inline-block"></div>var&nbsp;helper&nbsp;=&nbsp;function(wasAccepted,&nbsp;streamNames)&nbsp;{
<a name="line4915"></a><div class="linenumber">4915</div>
<a name="line4916"></a><div class="linenumber">4916</div><div style="width:8em;display:inline-block"></div>if&nbsp;(streamNames)&nbsp;{
<a name="line4917"></a><div class="linenumber">4917</div><div style="width:10em;display:inline-block"></div>if&nbsp;(typeof&nbsp;streamNames&nbsp;===&nbsp;"string")&nbsp;{
<a name="line4918"></a><div class="linenumber">4918</div><div style="width:12em;display:inline-block"></div>streamNames&nbsp;=&nbsp;[streamNames];
<a name="line4919"></a><div class="linenumber">4919</div><div style="width:10em;display:inline-block"></div>}
<a name="line4920"></a><div class="linenumber">4920</div><div style="width:10em;display:inline-block"></div>else&nbsp;if&nbsp;(streamNames.length&nbsp;===&nbsp;undefined)&nbsp;{
<a name="line4921"></a><div class="linenumber">4921</div><div style="width:12em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"accept&nbsp;callback&nbsp;passed&nbsp;invalid&nbsp;streamNames");
<a name="line4922"></a><div class="linenumber">4922</div><div style="width:12em;display:inline-block"></div>return;
<a name="line4923"></a><div class="linenumber">4923</div><div style="width:10em;display:inline-block"></div>}
<a name="line4924"></a><div class="linenumber">4924</div><div style="width:8em;display:inline-block"></div>}
<a name="line4925"></a><div class="linenumber">4925</div>
<a name="line4926"></a><div class="linenumber">4926</div><div style="width:8em;display:inline-block"></div>logDebug("offer&nbsp;accept="&nbsp;+&nbsp;wasAccepted);
<a name="line4927"></a><div class="linenumber">4927</div>
<a name="line4928"></a><div class="linenumber">4928</div><div style="width:8em;display:inline-block"></div>delete&nbsp;offersPending[caller];
<a name="line4929"></a><div class="linenumber">4929</div>
<a name="line4930"></a><div class="linenumber">4930</div><div style="width:8em;display:inline-block"></div>if&nbsp;(wasAccepted)&nbsp;{
<a name="line4931"></a><div class="linenumber">4931</div><div style="width:10em;display:inline-block"></div>if&nbsp;(!self.supportsPeerConnections())&nbsp;{
<a name="line4932"></a><div class="linenumber">4932</div><div style="width:12em;display:inline-block"></div>self.showError(self.errCodes.CALL_ERR,&nbsp;self.getConstantString("noWebrtcSupport"));
<a name="line4933"></a><div class="linenumber">4933</div><div style="width:12em;display:inline-block"></div>return;
<a name="line4934"></a><div class="linenumber">4934</div><div style="width:10em;display:inline-block"></div>}
<a name="line4935"></a><div class="linenumber">4935</div><div style="width:10em;display:inline-block"></div>doAnswer(caller,&nbsp;msgData,&nbsp;streamNames);
<a name="line4936"></a><div class="linenumber">4936</div><div style="width:10em;display:inline-block"></div>flushCachedCandidates(caller);
<a name="line4937"></a><div class="linenumber">4937</div><div style="width:8em;display:inline-block"></div>}
<a name="line4938"></a><div class="linenumber">4938</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line4939"></a><div class="linenumber">4939</div><div style="width:10em;display:inline-block"></div>sendSignalling(caller,&nbsp;"reject",&nbsp;null,&nbsp;null,&nbsp;null);
<a name="line4940"></a><div class="linenumber">4940</div><div style="width:10em;display:inline-block"></div>clearQueuedMessages(caller);
<a name="line4941"></a><div class="linenumber">4941</div><div style="width:8em;display:inline-block"></div>}
<a name="line4942"></a><div class="linenumber">4942</div><div style="width:6em;display:inline-block"></div>};
<a name="line4943"></a><div class="linenumber">4943</div><div style="width:6em;display:inline-block"></div>//
<a name="line4944"></a><div class="linenumber">4944</div><div style="width:6em;display:inline-block"></div>//&nbsp;There&nbsp;is&nbsp;a&nbsp;very&nbsp;rare&nbsp;case&nbsp;of&nbsp;two&nbsp;callers&nbsp;sending&nbsp;each&nbsp;other&nbsp;offers
<a name="line4945"></a><div class="linenumber">4945</div><div style="width:6em;display:inline-block"></div>//&nbsp;before&nbsp;receiving&nbsp;the&nbsp;others&nbsp;offer.&nbsp;In&nbsp;such&nbsp;a&nbsp;case,&nbsp;the&nbsp;caller&nbsp;with&nbsp;the
<a name="line4946"></a><div class="linenumber">4946</div><div style="width:6em;display:inline-block"></div>//&nbsp;greater&nbsp;valued&nbsp;easyrtcid&nbsp;will&nbsp;delete&nbsp;its&nbsp;pending&nbsp;call&nbsp;information&nbsp;and&nbsp;do&nbsp;a
<a name="line4947"></a><div class="linenumber">4947</div><div style="width:6em;display:inline-block"></div>//&nbsp;simple&nbsp;answer&nbsp;to&nbsp;the&nbsp;other&nbsp;caller's&nbsp;offer.
<a name="line4948"></a><div class="linenumber">4948</div><div style="width:6em;display:inline-block"></div>//
<a name="line4949"></a><div class="linenumber">4949</div><div style="width:6em;display:inline-block"></div>if&nbsp;(acceptancePending[caller]&nbsp;&amp;&amp;&nbsp;caller&nbsp;&lt;&nbsp;self.myEasyrtcid)&nbsp;{
<a name="line4950"></a><div class="linenumber">4950</div><div style="width:8em;display:inline-block"></div>delete&nbsp;acceptancePending[caller];
<a name="line4951"></a><div class="linenumber">4951</div><div style="width:8em;display:inline-block"></div>if&nbsp;(queuedMessages[caller])&nbsp;{
<a name="line4952"></a><div class="linenumber">4952</div><div style="width:10em;display:inline-block"></div>delete&nbsp;queuedMessages[caller];
<a name="line4953"></a><div class="linenumber">4953</div><div style="width:8em;display:inline-block"></div>}
<a name="line4954"></a><div class="linenumber">4954</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[caller])&nbsp;{
<a name="line4955"></a><div class="linenumber">4955</div><div style="width:10em;display:inline-block"></div>if&nbsp;(peerConns[caller].wasAcceptedCB)&nbsp;{
<a name="line4956"></a><div class="linenumber">4956</div><div style="width:12em;display:inline-block"></div>peerConns[caller].wasAcceptedCB(true,&nbsp;caller);
<a name="line4957"></a><div class="linenumber">4957</div><div style="width:10em;display:inline-block"></div>}
<a name="line4958"></a><div class="linenumber">4958</div><div style="width:10em;display:inline-block"></div>delete&nbsp;peerConns[caller];
<a name="line4959"></a><div class="linenumber">4959</div><div style="width:8em;display:inline-block"></div>}
<a name="line4960"></a><div class="linenumber">4960</div><div style="width:8em;display:inline-block"></div>helper(true);
<a name="line4961"></a><div class="linenumber">4961</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4962"></a><div class="linenumber">4962</div><div style="width:6em;display:inline-block"></div>}
<a name="line4963"></a><div class="linenumber">4963</div>
<a name="line4964"></a><div class="linenumber">4964</div><div style="width:6em;display:inline-block"></div>offersPending[caller]&nbsp;=&nbsp;msgData;
<a name="line4965"></a><div class="linenumber">4965</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!self.acceptCheck)&nbsp;{
<a name="line4966"></a><div class="linenumber">4966</div><div style="width:8em;display:inline-block"></div>helper(true);
<a name="line4967"></a><div class="linenumber">4967</div><div style="width:6em;display:inline-block"></div>}
<a name="line4968"></a><div class="linenumber">4968</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line4969"></a><div class="linenumber">4969</div><div style="width:8em;display:inline-block"></div>self.acceptCheck(caller,&nbsp;helper);
<a name="line4970"></a><div class="linenumber">4970</div><div style="width:6em;display:inline-block"></div>}
<a name="line4971"></a><div class="linenumber">4971</div><div style="width:4em;display:inline-block"></div>};
<a name="line4972"></a><div class="linenumber">4972</div>
<a name="line4973"></a><div class="linenumber">4973</div><div style="width:4em;display:inline-block"></div>function&nbsp;processReject(caller)&nbsp;{
<a name="line4974"></a><div class="linenumber">4974</div><div style="width:6em;display:inline-block"></div>delete&nbsp;acceptancePending[caller];
<a name="line4975"></a><div class="linenumber">4975</div><div style="width:6em;display:inline-block"></div>if&nbsp;(queuedMessages[caller])&nbsp;{
<a name="line4976"></a><div class="linenumber">4976</div><div style="width:8em;display:inline-block"></div>delete&nbsp;queuedMessages[caller];
<a name="line4977"></a><div class="linenumber">4977</div><div style="width:6em;display:inline-block"></div>}
<a name="line4978"></a><div class="linenumber">4978</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[caller])&nbsp;{
<a name="line4979"></a><div class="linenumber">4979</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[caller].wasAcceptedCB)&nbsp;{
<a name="line4980"></a><div class="linenumber">4980</div><div style="width:10em;display:inline-block"></div>peerConns[caller].wasAcceptedCB(false,&nbsp;caller);
<a name="line4981"></a><div class="linenumber">4981</div><div style="width:8em;display:inline-block"></div>}
<a name="line4982"></a><div class="linenumber">4982</div><div style="width:8em;display:inline-block"></div>delete&nbsp;peerConns[caller];
<a name="line4983"></a><div class="linenumber">4983</div><div style="width:6em;display:inline-block"></div>}
<a name="line4984"></a><div class="linenumber">4984</div><div style="width:4em;display:inline-block"></div>}
<a name="line4985"></a><div class="linenumber">4985</div>
<a name="line4986"></a><div class="linenumber">4986</div><div style="width:4em;display:inline-block"></div>function&nbsp;processAnswer(caller,&nbsp;msgData)&nbsp;{
<a name="line4987"></a><div class="linenumber">4987</div>
<a name="line4988"></a><div class="linenumber">4988</div><div style="width:6em;display:inline-block"></div>delete&nbsp;acceptancePending[caller];
<a name="line4989"></a><div class="linenumber">4989</div>
<a name="line4990"></a><div class="linenumber">4990</div><div style="width:6em;display:inline-block"></div>//
<a name="line4991"></a><div class="linenumber">4991</div><div style="width:6em;display:inline-block"></div>//&nbsp;if&nbsp;we've&nbsp;discarded&nbsp;the&nbsp;peer&nbsp;connection,&nbsp;ignore&nbsp;the&nbsp;answer.
<a name="line4992"></a><div class="linenumber">4992</div><div style="width:6em;display:inline-block"></div>//
<a name="line4993"></a><div class="linenumber">4993</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!peerConns[caller])&nbsp;{
<a name="line4994"></a><div class="linenumber">4994</div><div style="width:8em;display:inline-block"></div>return;
<a name="line4995"></a><div class="linenumber">4995</div><div style="width:6em;display:inline-block"></div>}
<a name="line4996"></a><div class="linenumber">4996</div><div style="width:6em;display:inline-block"></div>peerConns[caller].connectionAccepted&nbsp;=&nbsp;true;
<a name="line4997"></a><div class="linenumber">4997</div>
<a name="line4998"></a><div class="linenumber">4998</div>
<a name="line4999"></a><div class="linenumber">4999</div>
<a name="line5000"></a><div class="linenumber">5000</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[caller].wasAcceptedCB)&nbsp;{
<a name="line5001"></a><div class="linenumber">5001</div><div style="width:8em;display:inline-block"></div>peerConns[caller].wasAcceptedCB(true,&nbsp;caller);
<a name="line5002"></a><div class="linenumber">5002</div><div style="width:6em;display:inline-block"></div>}
<a name="line5003"></a><div class="linenumber">5003</div>
<a name="line5004"></a><div class="linenumber">5004</div><div style="width:6em;display:inline-block"></div>var&nbsp;onSignalSuccess&nbsp;=&nbsp;function()&nbsp;{
<a name="line5005"></a><div class="linenumber">5005</div>
<a name="line5006"></a><div class="linenumber">5006</div><div style="width:6em;display:inline-block"></div>};
<a name="line5007"></a><div class="linenumber">5007</div><div style="width:6em;display:inline-block"></div>var&nbsp;onSignalFailure&nbsp;=&nbsp;function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line5008"></a><div class="linenumber">5008</div><div style="width:8em;display:inline-block"></div>if&nbsp;(peerConns[caller])&nbsp;{
<a name="line5009"></a><div class="linenumber">5009</div><div style="width:10em;display:inline-block"></div>delete&nbsp;peerConns[caller];
<a name="line5010"></a><div class="linenumber">5010</div><div style="width:8em;display:inline-block"></div>}
<a name="line5011"></a><div class="linenumber">5011</div><div style="width:8em;display:inline-block"></div>self.showError(errorCode,&nbsp;errorText);
<a name="line5012"></a><div class="linenumber">5012</div><div style="width:6em;display:inline-block"></div>};
<a name="line5013"></a><div class="linenumber">5013</div><div style="width:6em;display:inline-block"></div>//&nbsp;peerConns[caller].startedAV&nbsp;=&nbsp;true;
<a name="line5014"></a><div class="linenumber">5014</div><div style="width:6em;display:inline-block"></div>sendQueuedCandidates(caller,&nbsp;onSignalSuccess,&nbsp;onSignalFailure);
<a name="line5015"></a><div class="linenumber">5015</div><div style="width:6em;display:inline-block"></div>pc&nbsp;=&nbsp;peerConns[caller].pc;
<a name="line5016"></a><div class="linenumber">5016</div><div style="width:6em;display:inline-block"></div>var&nbsp;sd&nbsp;=&nbsp;new&nbsp;RTCSessionDescription(msgData);
<a name="line5017"></a><div class="linenumber">5017</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!sd)&nbsp;{
<a name="line5018"></a><div class="linenumber">5018</div><div style="width:8em;display:inline-block"></div>throw&nbsp;"Could&nbsp;not&nbsp;create&nbsp;the&nbsp;RTCSessionDescription";
<a name="line5019"></a><div class="linenumber">5019</div><div style="width:6em;display:inline-block"></div>}
<a name="line5020"></a><div class="linenumber">5020</div>
<a name="line5021"></a><div class="linenumber">5021</div><div style="width:6em;display:inline-block"></div>logDebug("about&nbsp;to&nbsp;call&nbsp;initiating&nbsp;setRemoteDescription");
<a name="line5022"></a><div class="linenumber">5022</div>
<a name="line5023"></a><div class="linenumber">5023</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line5024"></a><div class="linenumber">5024</div><div style="width:8em;display:inline-block"></div>if&nbsp;(sdpRemoteFilter)&nbsp;{
<a name="line5025"></a><div class="linenumber">5025</div><div style="width:10em;display:inline-block"></div>sd.sdp&nbsp;=&nbsp;sdpRemoteFilter(sd.sdp);
<a name="line5026"></a><div class="linenumber">5026</div><div style="width:8em;display:inline-block"></div>}
<a name="line5027"></a><div class="linenumber">5027</div><div style="width:8em;display:inline-block"></div>pc.setRemoteDescription(sd,&nbsp;function()&nbsp;{
<a name="line5028"></a><div class="linenumber">5028</div><div style="width:10em;display:inline-block"></div>if&nbsp;(pc.connectDataConnection)&nbsp;{
<a name="line5029"></a><div class="linenumber">5029</div><div style="width:12em;display:inline-block"></div>logDebug("calling&nbsp;connectDataConnection(5001,5002)");
<a name="line5030"></a><div class="linenumber">5030</div>
<a name="line5031"></a><div class="linenumber">5031</div><div style="width:12em;display:inline-block"></div>pc.connectDataConnection(5001,&nbsp;5002);&nbsp;//&nbsp;these&nbsp;are&nbsp;like&nbsp;ids&nbsp;for&nbsp;data&nbsp;channels
<a name="line5032"></a><div class="linenumber">5032</div><div style="width:10em;display:inline-block"></div>}
<a name="line5033"></a><div class="linenumber">5033</div><div style="width:8em;display:inline-block"></div>},&nbsp;function(message){
<a name="line5034"></a><div class="linenumber">5034</div><div style="width:10em;display:inline-block"></div>logDebug("setRemoteDescription&nbsp;failed&nbsp;",&nbsp;message);
<a name="line5035"></a><div class="linenumber">5035</div><div style="width:8em;display:inline-block"></div>});
<a name="line5036"></a><div class="linenumber">5036</div><div style="width:6em;display:inline-block"></div>}&nbsp;catch&nbsp;(smdException)&nbsp;{
<a name="line5037"></a><div class="linenumber">5037</div><div style="width:8em;display:inline-block"></div>logDebug("setRemoteDescription&nbsp;failed&nbsp;",&nbsp;smdException);
<a name="line5038"></a><div class="linenumber">5038</div><div style="width:6em;display:inline-block"></div>}
<a name="line5039"></a><div class="linenumber">5039</div><div style="width:6em;display:inline-block"></div>flushCachedCandidates(caller);
<a name="line5040"></a><div class="linenumber">5040</div><div style="width:4em;display:inline-block"></div>}
<a name="line5041"></a><div class="linenumber">5041</div>
<a name="line5042"></a><div class="linenumber">5042</div><div style="width:4em;display:inline-block"></div>function&nbsp;processCandidateQueue(caller,&nbsp;msgData)&nbsp;{
<a name="line5043"></a><div class="linenumber">5043</div>
<a name="line5044"></a><div class="linenumber">5044</div><div style="width:6em;display:inline-block"></div>if&nbsp;(peerConns[caller]&nbsp;&amp;&amp;&nbsp;peerConns[caller].pc)&nbsp;{
<a name="line5045"></a><div class="linenumber">5045</div><div style="width:8em;display:inline-block"></div>processCandidateBody(caller,&nbsp;msgData);
<a name="line5046"></a><div class="linenumber">5046</div><div style="width:6em;display:inline-block"></div>}
<a name="line5047"></a><div class="linenumber">5047</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line5048"></a><div class="linenumber">5048</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!peerConns[caller])&nbsp;{
<a name="line5049"></a><div class="linenumber">5049</div><div style="width:10em;display:inline-block"></div>queuedMessages[caller]&nbsp;=&nbsp;{
<a name="line5050"></a><div class="linenumber">5050</div><div style="width:12em;display:inline-block"></div>candidates:&nbsp;[]
<a name="line5051"></a><div class="linenumber">5051</div><div style="width:10em;display:inline-block"></div>};
<a name="line5052"></a><div class="linenumber">5052</div><div style="width:8em;display:inline-block"></div>}
<a name="line5053"></a><div class="linenumber">5053</div><div style="width:8em;display:inline-block"></div>queuedMessages[caller].candidates.push(msgData);
<a name="line5054"></a><div class="linenumber">5054</div><div style="width:6em;display:inline-block"></div>}
<a name="line5055"></a><div class="linenumber">5055</div><div style="width:4em;display:inline-block"></div>}
<a name="line5056"></a><div class="linenumber">5056</div>
<a name="line5057"></a><div class="linenumber">5057</div><div style="width:4em;display:inline-block"></div>switch&nbsp;(msgType)&nbsp;{
<a name="line5058"></a><div class="linenumber">5058</div><div style="width:6em;display:inline-block"></div>case&nbsp;"sessionData":
<a name="line5059"></a><div class="linenumber">5059</div><div style="width:8em;display:inline-block"></div>processSessionData(msgData.sessionData);
<a name="line5060"></a><div class="linenumber">5060</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5061"></a><div class="linenumber">5061</div><div style="width:6em;display:inline-block"></div>case&nbsp;"roomData":
<a name="line5062"></a><div class="linenumber">5062</div><div style="width:8em;display:inline-block"></div>processRoomData(msgData.roomData);
<a name="line5063"></a><div class="linenumber">5063</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5064"></a><div class="linenumber">5064</div><div style="width:6em;display:inline-block"></div>case&nbsp;"iceConfig":
<a name="line5065"></a><div class="linenumber">5065</div><div style="width:8em;display:inline-block"></div>processIceConfig(msgData.iceConfig);
<a name="line5066"></a><div class="linenumber">5066</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5067"></a><div class="linenumber">5067</div><div style="width:6em;display:inline-block"></div>case&nbsp;"forwardToUrl":
<a name="line5068"></a><div class="linenumber">5068</div><div style="width:8em;display:inline-block"></div>if&nbsp;(msgData.newWindow)&nbsp;{
<a name="line5069"></a><div class="linenumber">5069</div><div style="width:10em;display:inline-block"></div>window.open(msgData.forwardToUrl.url);
<a name="line5070"></a><div class="linenumber">5070</div><div style="width:8em;display:inline-block"></div>}
<a name="line5071"></a><div class="linenumber">5071</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line5072"></a><div class="linenumber">5072</div><div style="width:10em;display:inline-block"></div>window.location.href&nbsp;=&nbsp;msgData.forwardToUrl.url;
<a name="line5073"></a><div class="linenumber">5073</div><div style="width:8em;display:inline-block"></div>}
<a name="line5074"></a><div class="linenumber">5074</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5075"></a><div class="linenumber">5075</div><div style="width:6em;display:inline-block"></div>case&nbsp;"offer":
<a name="line5076"></a><div class="linenumber">5076</div><div style="width:8em;display:inline-block"></div>processOffer(caller,&nbsp;msgData);
<a name="line5077"></a><div class="linenumber">5077</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5078"></a><div class="linenumber">5078</div><div style="width:6em;display:inline-block"></div>case&nbsp;"reject":
<a name="line5079"></a><div class="linenumber">5079</div><div style="width:8em;display:inline-block"></div>processReject(caller);
<a name="line5080"></a><div class="linenumber">5080</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5081"></a><div class="linenumber">5081</div><div style="width:6em;display:inline-block"></div>case&nbsp;"answer":
<a name="line5082"></a><div class="linenumber">5082</div><div style="width:8em;display:inline-block"></div>processAnswer(caller,&nbsp;msgData);
<a name="line5083"></a><div class="linenumber">5083</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5084"></a><div class="linenumber">5084</div><div style="width:6em;display:inline-block"></div>case&nbsp;"candidate":
<a name="line5085"></a><div class="linenumber">5085</div><div style="width:8em;display:inline-block"></div>processCandidateQueue(caller,&nbsp;msgData);
<a name="line5086"></a><div class="linenumber">5086</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5087"></a><div class="linenumber">5087</div><div style="width:6em;display:inline-block"></div>case&nbsp;"hangup":
<a name="line5088"></a><div class="linenumber">5088</div><div style="width:8em;display:inline-block"></div>onRemoteHangup(caller);
<a name="line5089"></a><div class="linenumber">5089</div><div style="width:8em;display:inline-block"></div>clearQueuedMessages(caller);
<a name="line5090"></a><div class="linenumber">5090</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5091"></a><div class="linenumber">5091</div><div style="width:6em;display:inline-block"></div>case&nbsp;"error":
<a name="line5092"></a><div class="linenumber">5092</div><div style="width:8em;display:inline-block"></div>self.showError(msgData.errorCode,&nbsp;msgData.errorText);
<a name="line5093"></a><div class="linenumber">5093</div><div style="width:8em;display:inline-block"></div>break;
<a name="line5094"></a><div class="linenumber">5094</div><div style="width:6em;display:inline-block"></div>default:
<a name="line5095"></a><div class="linenumber">5095</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"received&nbsp;unknown&nbsp;message&nbsp;type&nbsp;from&nbsp;server,&nbsp;msgType&nbsp;is&nbsp;"&nbsp;+&nbsp;msgType);
<a name="line5096"></a><div class="linenumber">5096</div><div style="width:8em;display:inline-block"></div>return;
<a name="line5097"></a><div class="linenumber">5097</div><div style="width:4em;display:inline-block"></div>}
<a name="line5098"></a><div class="linenumber">5098</div>
<a name="line5099"></a><div class="linenumber">5099</div><div style="width:4em;display:inline-block"></div>if&nbsp;(ackAcceptorFn)&nbsp;{
<a name="line5100"></a><div class="linenumber">5100</div><div style="width:6em;display:inline-block"></div>ackAcceptorFn(self.ackMessage);
<a name="line5101"></a><div class="linenumber">5101</div><div style="width:4em;display:inline-block"></div>}
<a name="line5102"></a><div class="linenumber">5102</div><div style="width:2em;display:inline-block"></div>}
<a name="line5103"></a><div class="linenumber">5103</div>
<a name="line5104"></a><div class="linenumber">5104</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5105"></a><div class="linenumber">5105</div><div style="width:2em;display:inline-block"></div>*&nbsp;Sets&nbsp;the&nbsp;presence&nbsp;state&nbsp;on&nbsp;the&nbsp;server.
<a name="line5106"></a><div class="linenumber">5106</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;state&nbsp;-&nbsp;one&nbsp;of&nbsp;'away','chat','dnd','xa'
<a name="line5107"></a><div class="linenumber">5107</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;statusText&nbsp;-&nbsp;User&nbsp;configurable&nbsp;status&nbsp;string.&nbsp;May&nbsp;be&nbsp;length&nbsp;limited.
<a name="line5108"></a><div class="linenumber">5108</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example&nbsp;&nbsp;&nbsp;easyrtc.updatePresence('dnd',&nbsp;'sleeping');
<a name="line5109"></a><div class="linenumber">5109</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5110"></a><div class="linenumber">5110</div><div style="width:2em;display:inline-block"></div>this.updatePresence&nbsp;=&nbsp;function(state,&nbsp;statusText)&nbsp;{
<a name="line5111"></a><div class="linenumber">5111</div>
<a name="line5112"></a><div class="linenumber">5112</div><div style="width:4em;display:inline-block"></div>self.presenceShow&nbsp;=&nbsp;state;
<a name="line5113"></a><div class="linenumber">5113</div><div style="width:4em;display:inline-block"></div>self.presenceStatus&nbsp;=&nbsp;statusText;
<a name="line5114"></a><div class="linenumber">5114</div>
<a name="line5115"></a><div class="linenumber">5115</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.webSocketConnected)&nbsp;{
<a name="line5116"></a><div class="linenumber">5116</div><div style="width:6em;display:inline-block"></div>sendSignalling(null,&nbsp;'setPresence',&nbsp;{
<a name="line5117"></a><div class="linenumber">5117</div><div style="width:8em;display:inline-block"></div>setPresence:&nbsp;{
<a name="line5118"></a><div class="linenumber">5118</div><div style="width:10em;display:inline-block"></div>'show':&nbsp;self.presenceShow,
<a name="line5119"></a><div class="linenumber">5119</div><div style="width:10em;display:inline-block"></div>'status':&nbsp;self.presenceStatus
<a name="line5120"></a><div class="linenumber">5120</div><div style="width:8em;display:inline-block"></div>}
<a name="line5121"></a><div class="linenumber">5121</div><div style="width:6em;display:inline-block"></div>},&nbsp;null);
<a name="line5122"></a><div class="linenumber">5122</div><div style="width:4em;display:inline-block"></div>}
<a name="line5123"></a><div class="linenumber">5123</div><div style="width:2em;display:inline-block"></div>};
<a name="line5124"></a><div class="linenumber">5124</div>
<a name="line5125"></a><div class="linenumber">5125</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5126"></a><div class="linenumber">5126</div><div style="width:2em;display:inline-block"></div>*&nbsp;Fetch&nbsp;the&nbsp;collection&nbsp;of&nbsp;session&nbsp;fields&nbsp;as&nbsp;a&nbsp;map.&nbsp;The&nbsp;map&nbsp;has&nbsp;the&nbsp;structure:
<a name="line5127"></a><div class="linenumber">5127</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;{key1:&nbsp;{"fieldName":&nbsp;key1,&nbsp;"fieldValue":&nbsp;value1},&nbsp;...,
<a name="line5128"></a><div class="linenumber">5128</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;key2:&nbsp;{"fieldName":&nbsp;key2,&nbsp;"fieldValue":&nbsp;value2}
<a name="line5129"></a><div class="linenumber">5129</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;}
<a name="line5130"></a><div class="linenumber">5130</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}
<a name="line5131"></a><div class="linenumber">5131</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5132"></a><div class="linenumber">5132</div><div style="width:2em;display:inline-block"></div>this.getSessionFields&nbsp;=&nbsp;function()&nbsp;{
<a name="line5133"></a><div class="linenumber">5133</div><div style="width:4em;display:inline-block"></div>return&nbsp;sessionFields;
<a name="line5134"></a><div class="linenumber">5134</div><div style="width:2em;display:inline-block"></div>};
<a name="line5135"></a><div class="linenumber">5135</div>
<a name="line5136"></a><div class="linenumber">5136</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5137"></a><div class="linenumber">5137</div><div style="width:2em;display:inline-block"></div>*&nbsp;Fetch&nbsp;the&nbsp;value&nbsp;of&nbsp;a&nbsp;session&nbsp;field&nbsp;by&nbsp;name.
<a name="line5138"></a><div class="linenumber">5138</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;name&nbsp;-&nbsp;name&nbsp;of&nbsp;the&nbsp;session&nbsp;field&nbsp;to&nbsp;be&nbsp;fetched.
<a name="line5139"></a><div class="linenumber">5139</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;the&nbsp;field&nbsp;value&nbsp;(which&nbsp;can&nbsp;be&nbsp;anything).&nbsp;Returns&nbsp;undefined&nbsp;if&nbsp;the&nbsp;field&nbsp;does&nbsp;not&nbsp;exist.
<a name="line5140"></a><div class="linenumber">5140</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5141"></a><div class="linenumber">5141</div><div style="width:2em;display:inline-block"></div>this.getSessionField&nbsp;=&nbsp;function(name)&nbsp;{
<a name="line5142"></a><div class="linenumber">5142</div><div style="width:4em;display:inline-block"></div>if&nbsp;(sessionFields[name])&nbsp;{
<a name="line5143"></a><div class="linenumber">5143</div><div style="width:6em;display:inline-block"></div>return&nbsp;sessionFields[name].fieldValue;
<a name="line5144"></a><div class="linenumber">5144</div><div style="width:4em;display:inline-block"></div>}
<a name="line5145"></a><div class="linenumber">5145</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line5146"></a><div class="linenumber">5146</div><div style="width:6em;display:inline-block"></div>return&nbsp;undefined;
<a name="line5147"></a><div class="linenumber">5147</div><div style="width:4em;display:inline-block"></div>}
<a name="line5148"></a><div class="linenumber">5148</div><div style="width:2em;display:inline-block"></div>};
<a name="line5149"></a><div class="linenumber">5149</div>
<a name="line5150"></a><div class="linenumber">5150</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5151"></a><div class="linenumber">5151</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;an&nbsp;array&nbsp;of&nbsp;easyrtcid's&nbsp;of&nbsp;peers&nbsp;in&nbsp;a&nbsp;particular&nbsp;room.
<a name="line5152"></a><div class="linenumber">5152</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;roomName
<a name="line5153"></a><div class="linenumber">5153</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Array}&nbsp;of&nbsp;easyrtcids&nbsp;or&nbsp;null&nbsp;if&nbsp;the&nbsp;client&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;room.
<a name="line5154"></a><div class="linenumber">5154</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line5155"></a><div class="linenumber">5155</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;occupants&nbsp;=&nbsp;easyrtc.getRoomOccupants("default");
<a name="line5156"></a><div class="linenumber">5156</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;i;
<a name="line5157"></a><div class="linenumber">5157</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;occupants.length;&nbsp;i++&nbsp;)&nbsp;{
<a name="line5158"></a><div class="linenumber">5158</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(&nbsp;occupants[i]&nbsp;+&nbsp;"&nbsp;is&nbsp;in&nbsp;the&nbsp;room");
<a name="line5159"></a><div class="linenumber">5159</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line5160"></a><div class="linenumber">5160</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5161"></a><div class="linenumber">5161</div><div style="width:2em;display:inline-block"></div>this.getRoomOccupantsAsArray&nbsp;=&nbsp;function(roomName)&nbsp;{
<a name="line5162"></a><div class="linenumber">5162</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!lastLoggedInList[roomName])&nbsp;{
<a name="line5163"></a><div class="linenumber">5163</div><div style="width:6em;display:inline-block"></div>return&nbsp;null;
<a name="line5164"></a><div class="linenumber">5164</div><div style="width:4em;display:inline-block"></div>}
<a name="line5165"></a><div class="linenumber">5165</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line5166"></a><div class="linenumber">5166</div><div style="width:6em;display:inline-block"></div>return&nbsp;Object.keys(lastLoggedInList[roomName]);
<a name="line5167"></a><div class="linenumber">5167</div><div style="width:4em;display:inline-block"></div>}
<a name="line5168"></a><div class="linenumber">5168</div><div style="width:2em;display:inline-block"></div>};
<a name="line5169"></a><div class="linenumber">5169</div>
<a name="line5170"></a><div class="linenumber">5170</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5171"></a><div class="linenumber">5171</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;a&nbsp;map&nbsp;of&nbsp;easyrtcid's&nbsp;of&nbsp;peers&nbsp;in&nbsp;a&nbsp;particular&nbsp;room.&nbsp;You&nbsp;should&nbsp;only&nbsp;test&nbsp;elements&nbsp;in&nbsp;the&nbsp;map&nbsp;to&nbsp;see&nbsp;if&nbsp;they&nbsp;are
<a name="line5172"></a><div class="linenumber">5172</div><div style="width:2em;display:inline-block"></div>*&nbsp;null;&nbsp;their&nbsp;actual&nbsp;values&nbsp;are&nbsp;not&nbsp;guaranteed&nbsp;to&nbsp;be&nbsp;the&nbsp;same&nbsp;in&nbsp;different&nbsp;releases.
<a name="line5173"></a><div class="linenumber">5173</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;roomName
<a name="line5174"></a><div class="linenumber">5174</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;of&nbsp;easyrtcids&nbsp;or&nbsp;null&nbsp;if&nbsp;the&nbsp;client&nbsp;is&nbsp;not&nbsp;in&nbsp;the&nbsp;room.
<a name="line5175"></a><div class="linenumber">5175</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line5176"></a><div class="linenumber">5176</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;easyrtc.getRoomOccupantsAsMap("default")[some_easyrtcid])&nbsp;{
<a name="line5177"></a><div class="linenumber">5177</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("yep,&nbsp;"&nbsp;+&nbsp;some_easyrtcid&nbsp;+&nbsp;"&nbsp;is&nbsp;in&nbsp;the&nbsp;room");
<a name="line5178"></a><div class="linenumber">5178</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<a name="line5179"></a><div class="linenumber">5179</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5180"></a><div class="linenumber">5180</div><div style="width:2em;display:inline-block"></div>this.getRoomOccupantsAsMap&nbsp;=&nbsp;function(roomName)&nbsp;{
<a name="line5181"></a><div class="linenumber">5181</div><div style="width:4em;display:inline-block"></div>return&nbsp;lastLoggedInList[roomName];
<a name="line5182"></a><div class="linenumber">5182</div><div style="width:2em;display:inline-block"></div>};
<a name="line5183"></a><div class="linenumber">5183</div>
<a name="line5184"></a><div class="linenumber">5184</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5185"></a><div class="linenumber">5185</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;true&nbsp;if&nbsp;the&nbsp;ipAddress&nbsp;parameter&nbsp;was&nbsp;the&nbsp;address&nbsp;of&nbsp;a&nbsp;turn&nbsp;server.&nbsp;This&nbsp;is&nbsp;done&nbsp;by&nbsp;checking&nbsp;against&nbsp;information
<a name="line5186"></a><div class="linenumber">5186</div><div style="width:2em;display:inline-block"></div>*&nbsp;collected&nbsp;during&nbsp;peer&nbsp;to&nbsp;peer&nbsp;calls.&nbsp;Don't&nbsp;expect&nbsp;it&nbsp;to&nbsp;work&nbsp;before&nbsp;the&nbsp;first&nbsp;call,&nbsp;or&nbsp;to&nbsp;identify&nbsp;turn&nbsp;servers&nbsp;that&nbsp;aren't
<a name="line5187"></a><div class="linenumber">5187</div><div style="width:2em;display:inline-block"></div>*&nbsp;in&nbsp;the&nbsp;ice&nbsp;config.
<a name="line5188"></a><div class="linenumber">5188</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;ipAddress
<a name="line5189"></a><div class="linenumber">5189</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{boolean}&nbsp;true&nbsp;if&nbsp;ip&nbsp;address&nbsp;is&nbsp;known&nbsp;to&nbsp;be&nbsp;that&nbsp;of&nbsp;a&nbsp;turn&nbsp;server,&nbsp;false&nbsp;otherwise.
<a name="line5190"></a><div class="linenumber">5190</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5191"></a><div class="linenumber">5191</div><div style="width:2em;display:inline-block"></div>this.isTurnServer&nbsp;=&nbsp;function(ipAddress)&nbsp;{
<a name="line5192"></a><div class="linenumber">5192</div><div style="width:4em;display:inline-block"></div>return&nbsp;!!self._turnServers[ipAddress];
<a name="line5193"></a><div class="linenumber">5193</div><div style="width:2em;display:inline-block"></div>};
<a name="line5194"></a><div class="linenumber">5194</div>
<a name="line5195"></a><div class="linenumber">5195</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5196"></a><div class="linenumber">5196</div><div style="width:2em;display:inline-block"></div>*&nbsp;Returns&nbsp;true&nbsp;if&nbsp;the&nbsp;ipAddress&nbsp;parameter&nbsp;was&nbsp;the&nbsp;address&nbsp;of&nbsp;a&nbsp;stun&nbsp;server.&nbsp;This&nbsp;is&nbsp;done&nbsp;by&nbsp;checking&nbsp;against&nbsp;information
<a name="line5197"></a><div class="linenumber">5197</div><div style="width:2em;display:inline-block"></div>*&nbsp;collected&nbsp;during&nbsp;peer&nbsp;to&nbsp;peer&nbsp;calls.&nbsp;Don't&nbsp;expect&nbsp;it&nbsp;to&nbsp;work&nbsp;before&nbsp;the&nbsp;first&nbsp;call,&nbsp;or&nbsp;to&nbsp;identify&nbsp;turn&nbsp;servers&nbsp;that&nbsp;aren't
<a name="line5198"></a><div class="linenumber">5198</div><div style="width:2em;display:inline-block"></div>*&nbsp;in&nbsp;the&nbsp;ice&nbsp;config.
<a name="line5199"></a><div class="linenumber">5199</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{string}&nbsp;ipAddress
<a name="line5200"></a><div class="linenumber">5200</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{boolean}&nbsp;true&nbsp;if&nbsp;ip&nbsp;address&nbsp;is&nbsp;known&nbsp;to&nbsp;be&nbsp;that&nbsp;of&nbsp;a&nbsp;stun&nbsp;server,&nbsp;false&nbsp;otherwise.
<a name="line5201"></a><div class="linenumber">5201</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5202"></a><div class="linenumber">5202</div><div style="width:2em;display:inline-block"></div>this.isStunServer&nbsp;=&nbsp;function(ipAddress)&nbsp;{
<a name="line5203"></a><div class="linenumber">5203</div><div style="width:4em;display:inline-block"></div>return&nbsp;!!self._stunServers[ipAddress];
<a name="line5204"></a><div class="linenumber">5204</div><div style="width:2em;display:inline-block"></div>};
<a name="line5205"></a><div class="linenumber">5205</div>
<a name="line5206"></a><div class="linenumber">5206</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5207"></a><div class="linenumber">5207</div><div style="width:2em;display:inline-block"></div>*&nbsp;Request&nbsp;fresh&nbsp;ice&nbsp;config&nbsp;information&nbsp;from&nbsp;the&nbsp;server.
<a name="line5208"></a><div class="linenumber">5208</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;should&nbsp;be&nbsp;done&nbsp;periodically&nbsp;by&nbsp;long&nbsp;running&nbsp;applications.
<a name="line5209"></a><div class="linenumber">5209</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;callback&nbsp;is&nbsp;called&nbsp;with&nbsp;a&nbsp;value&nbsp;of&nbsp;true&nbsp;on&nbsp;success,&nbsp;false&nbsp;on&nbsp;failure.
<a name="line5210"></a><div class="linenumber">5210</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5211"></a><div class="linenumber">5211</div><div style="width:2em;display:inline-block"></div>this.getFreshIceConfig&nbsp;=&nbsp;function(callback)&nbsp;{
<a name="line5212"></a><div class="linenumber">5212</div><div style="width:4em;display:inline-block"></div>var&nbsp;dataToShip&nbsp;=&nbsp;{
<a name="line5213"></a><div class="linenumber">5213</div><div style="width:6em;display:inline-block"></div>msgType:&nbsp;"getIceConfig",
<a name="line5214"></a><div class="linenumber">5214</div><div style="width:6em;display:inline-block"></div>msgData:&nbsp;{}
<a name="line5215"></a><div class="linenumber">5215</div><div style="width:4em;display:inline-block"></div>};
<a name="line5216"></a><div class="linenumber">5216</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!callback)&nbsp;{
<a name="line5217"></a><div class="linenumber">5217</div><div style="width:6em;display:inline-block"></div>callback&nbsp;=&nbsp;function()&nbsp;{
<a name="line5218"></a><div class="linenumber">5218</div><div style="width:6em;display:inline-block"></div>};
<a name="line5219"></a><div class="linenumber">5219</div><div style="width:4em;display:inline-block"></div>}
<a name="line5220"></a><div class="linenumber">5220</div><div style="width:4em;display:inline-block"></div>self.webSocket.json.emit("easyrtcCmd",&nbsp;dataToShip,
<a name="line5221"></a><div class="linenumber">5221</div><div style="width:8em;display:inline-block"></div>function(ackMsg)&nbsp;{
<a name="line5222"></a><div class="linenumber">5222</div><div style="width:10em;display:inline-block"></div>if&nbsp;(ackMsg.msgType&nbsp;===&nbsp;"iceConfig")&nbsp;{
<a name="line5223"></a><div class="linenumber">5223</div><div style="width:12em;display:inline-block"></div>processIceConfig(ackMsg.msgData.iceConfig);
<a name="line5224"></a><div class="linenumber">5224</div><div style="width:12em;display:inline-block"></div>callback(true);
<a name="line5225"></a><div class="linenumber">5225</div><div style="width:10em;display:inline-block"></div>}
<a name="line5226"></a><div class="linenumber">5226</div><div style="width:10em;display:inline-block"></div>else&nbsp;{
<a name="line5227"></a><div class="linenumber">5227</div><div style="width:12em;display:inline-block"></div>self.showError(ackMsg.msgData.errorCode,&nbsp;ackMsg.msgData.errorText);
<a name="line5228"></a><div class="linenumber">5228</div><div style="width:12em;display:inline-block"></div>callback(false);
<a name="line5229"></a><div class="linenumber">5229</div><div style="width:10em;display:inline-block"></div>}
<a name="line5230"></a><div class="linenumber">5230</div><div style="width:8em;display:inline-block"></div>}
<a name="line5231"></a><div class="linenumber">5231</div><div style="width:4em;display:inline-block"></div>);
<a name="line5232"></a><div class="linenumber">5232</div><div style="width:2em;display:inline-block"></div>};
<a name="line5233"></a><div class="linenumber">5233</div>
<a name="line5234"></a><div class="linenumber">5234</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5235"></a><div class="linenumber">5235</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;method&nbsp;allows&nbsp;you&nbsp;to&nbsp;join&nbsp;a&nbsp;single&nbsp;room.&nbsp;It&nbsp;may&nbsp;be&nbsp;called&nbsp;multiple&nbsp;times&nbsp;to&nbsp;be&nbsp;in
<a name="line5236"></a><div class="linenumber">5236</div><div style="width:2em;display:inline-block"></div>*&nbsp;multiple&nbsp;rooms&nbsp;simultaneously.&nbsp;It&nbsp;may&nbsp;be&nbsp;called&nbsp;before&nbsp;or&nbsp;after&nbsp;connecting&nbsp;to&nbsp;the&nbsp;server.
<a name="line5237"></a><div class="linenumber">5237</div><div style="width:2em;display:inline-block"></div>*&nbsp;Note:&nbsp;the&nbsp;successCB&nbsp;and&nbsp;failureDB&nbsp;will&nbsp;only&nbsp;be&nbsp;called&nbsp;if&nbsp;you&nbsp;are&nbsp;already&nbsp;connected&nbsp;to&nbsp;the&nbsp;server.
<a name="line5238"></a><div class="linenumber">5238</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;roomName&nbsp;the&nbsp;room&nbsp;to&nbsp;be&nbsp;joined.
<a name="line5239"></a><div class="linenumber">5239</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;roomParameters&nbsp;application&nbsp;specific&nbsp;parameters,&nbsp;can&nbsp;be&nbsp;null.
<a name="line5240"></a><div class="linenumber">5240</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;successCB&nbsp;called&nbsp;once,&nbsp;with&nbsp;a&nbsp;roomName&nbsp;as&nbsp;it's&nbsp;argument,&nbsp;once&nbsp;the&nbsp;room&nbsp;is&nbsp;joined.
<a name="line5241"></a><div class="linenumber">5241</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;failureCB&nbsp;called&nbsp;if&nbsp;the&nbsp;room&nbsp;can&nbsp;not&nbsp;be&nbsp;joined.&nbsp;The&nbsp;arguments&nbsp;of&nbsp;failureCB&nbsp;are&nbsp;errorCode,&nbsp;errorText,&nbsp;roomName.
<a name="line5242"></a><div class="linenumber">5242</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5243"></a><div class="linenumber">5243</div><div style="width:2em;display:inline-block"></div>this.joinRoom&nbsp;=&nbsp;function(roomName,&nbsp;roomParameters,&nbsp;successCB,&nbsp;failureCB)&nbsp;{
<a name="line5244"></a><div class="linenumber">5244</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.roomJoin[roomName])&nbsp;{
<a name="line5245"></a><div class="linenumber">5245</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Attempt&nbsp;to&nbsp;join&nbsp;room&nbsp;"&nbsp;+&nbsp;roomName&nbsp;+&nbsp;"&nbsp;which&nbsp;you&nbsp;are&nbsp;already&nbsp;in.");
<a name="line5246"></a><div class="linenumber">5246</div><div style="width:6em;display:inline-block"></div>return;
<a name="line5247"></a><div class="linenumber">5247</div><div style="width:4em;display:inline-block"></div>}
<a name="line5248"></a><div class="linenumber">5248</div>
<a name="line5249"></a><div class="linenumber">5249</div><div style="width:4em;display:inline-block"></div>var&nbsp;newRoomData&nbsp;=&nbsp;{roomName:&nbsp;roomName};
<a name="line5250"></a><div class="linenumber">5250</div><div style="width:4em;display:inline-block"></div>if&nbsp;(roomParameters)&nbsp;{
<a name="line5251"></a><div class="linenumber">5251</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line5252"></a><div class="linenumber">5252</div><div style="width:8em;display:inline-block"></div>JSON.stringify(roomParameters);
<a name="line5253"></a><div class="linenumber">5253</div><div style="width:6em;display:inline-block"></div>}&nbsp;catch&nbsp;(error)&nbsp;{
<a name="line5254"></a><div class="linenumber">5254</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"non-jsonable&nbsp;parameter&nbsp;to&nbsp;easyrtc.joinRoom");
<a name="line5255"></a><div class="linenumber">5255</div><div style="width:8em;display:inline-block"></div>throw&nbsp;"Developer&nbsp;error,&nbsp;see&nbsp;application&nbsp;error&nbsp;messages";
<a name="line5256"></a><div class="linenumber">5256</div><div style="width:6em;display:inline-block"></div>}
<a name="line5257"></a><div class="linenumber">5257</div><div style="width:6em;display:inline-block"></div>var&nbsp;parameters&nbsp;=&nbsp;{};
<a name="line5258"></a><div class="linenumber">5258</div><div style="width:6em;display:inline-block"></div>for&nbsp;(var&nbsp;key&nbsp;in&nbsp;roomParameters)&nbsp;{
<a name="line5259"></a><div class="linenumber">5259</div><div style="width:8em;display:inline-block"></div>if&nbsp;(roomParameters.hasOwnProperty(key))&nbsp;{
<a name="line5260"></a><div class="linenumber">5260</div><div style="width:10em;display:inline-block"></div>parameters[key]&nbsp;=&nbsp;roomParameters[key];
<a name="line5261"></a><div class="linenumber">5261</div><div style="width:8em;display:inline-block"></div>}
<a name="line5262"></a><div class="linenumber">5262</div><div style="width:6em;display:inline-block"></div>}
<a name="line5263"></a><div class="linenumber">5263</div><div style="width:6em;display:inline-block"></div>newRoomData.roomParameter&nbsp;=&nbsp;parameters;
<a name="line5264"></a><div class="linenumber">5264</div><div style="width:4em;display:inline-block"></div>}
<a name="line5265"></a><div class="linenumber">5265</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgData&nbsp;=&nbsp;{
<a name="line5266"></a><div class="linenumber">5266</div><div style="width:6em;display:inline-block"></div>roomJoin:&nbsp;{}
<a name="line5267"></a><div class="linenumber">5267</div><div style="width:4em;display:inline-block"></div>};
<a name="line5268"></a><div class="linenumber">5268</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomData;
<a name="line5269"></a><div class="linenumber">5269</div><div style="width:4em;display:inline-block"></div>var&nbsp;signallingSuccess,&nbsp;signallingFailure;
<a name="line5270"></a><div class="linenumber">5270</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.webSocket)&nbsp;{
<a name="line5271"></a><div class="linenumber">5271</div>
<a name="line5272"></a><div class="linenumber">5272</div><div style="width:6em;display:inline-block"></div>msgData.roomJoin[roomName]&nbsp;=&nbsp;newRoomData;
<a name="line5273"></a><div class="linenumber">5273</div><div style="width:6em;display:inline-block"></div>signallingSuccess&nbsp;=&nbsp;function(msgType,&nbsp;msgData)&nbsp;{
<a name="line5274"></a><div class="linenumber">5274</div>
<a name="line5275"></a><div class="linenumber">5275</div><div style="width:8em;display:inline-block"></div>roomData&nbsp;=&nbsp;msgData.roomData;
<a name="line5276"></a><div class="linenumber">5276</div><div style="width:8em;display:inline-block"></div>self.roomJoin[roomName]&nbsp;=&nbsp;newRoomData;
<a name="line5277"></a><div class="linenumber">5277</div><div style="width:8em;display:inline-block"></div>if&nbsp;(successCB)&nbsp;{
<a name="line5278"></a><div class="linenumber">5278</div><div style="width:10em;display:inline-block"></div>successCB(roomName);
<a name="line5279"></a><div class="linenumber">5279</div><div style="width:8em;display:inline-block"></div>}
<a name="line5280"></a><div class="linenumber">5280</div>
<a name="line5281"></a><div class="linenumber">5281</div><div style="width:8em;display:inline-block"></div>processRoomData(roomData);
<a name="line5282"></a><div class="linenumber">5282</div><div style="width:6em;display:inline-block"></div>};
<a name="line5283"></a><div class="linenumber">5283</div><div style="width:6em;display:inline-block"></div>signallingFailure&nbsp;=&nbsp;function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line5284"></a><div class="linenumber">5284</div><div style="width:8em;display:inline-block"></div>if&nbsp;(failureCB)&nbsp;{
<a name="line5285"></a><div class="linenumber">5285</div><div style="width:10em;display:inline-block"></div>failureCB(errorCode,&nbsp;errorText,&nbsp;roomName);
<a name="line5286"></a><div class="linenumber">5286</div><div style="width:8em;display:inline-block"></div>}
<a name="line5287"></a><div class="linenumber">5287</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line5288"></a><div class="linenumber">5288</div><div style="width:10em;display:inline-block"></div>self.showError(errorCode,&nbsp;self.format(self.getConstantString("unableToEnterRoom"),&nbsp;roomName,&nbsp;errorText));
<a name="line5289"></a><div class="linenumber">5289</div><div style="width:8em;display:inline-block"></div>}
<a name="line5290"></a><div class="linenumber">5290</div><div style="width:6em;display:inline-block"></div>};
<a name="line5291"></a><div class="linenumber">5291</div><div style="width:6em;display:inline-block"></div>sendSignalling(null,&nbsp;"roomJoin",&nbsp;msgData,&nbsp;signallingSuccess,&nbsp;signallingFailure);
<a name="line5292"></a><div class="linenumber">5292</div><div style="width:4em;display:inline-block"></div>}
<a name="line5293"></a><div class="linenumber">5293</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line5294"></a><div class="linenumber">5294</div><div style="width:6em;display:inline-block"></div>self.roomJoin[roomName]&nbsp;=&nbsp;newRoomData;
<a name="line5295"></a><div class="linenumber">5295</div><div style="width:4em;display:inline-block"></div>}
<a name="line5296"></a><div class="linenumber">5296</div>
<a name="line5297"></a><div class="linenumber">5297</div><div style="width:2em;display:inline-block"></div>};
<a name="line5298"></a><div class="linenumber">5298</div>
<a name="line5299"></a><div class="linenumber">5299</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5300"></a><div class="linenumber">5300</div><div style="width:2em;display:inline-block"></div>*&nbsp;This&nbsp;function&nbsp;allows&nbsp;you&nbsp;to&nbsp;leave&nbsp;a&nbsp;single&nbsp;room.&nbsp;Note:&nbsp;the&nbsp;successCB&nbsp;and&nbsp;failureDB
<a name="line5301"></a><div class="linenumber">5301</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;arguments&nbsp;are&nbsp;optional&nbsp;and&nbsp;will&nbsp;only&nbsp;be&nbsp;called&nbsp;if&nbsp;you&nbsp;are&nbsp;already&nbsp;connected&nbsp;to&nbsp;the&nbsp;server.
<a name="line5302"></a><div class="linenumber">5302</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;roomName
<a name="line5303"></a><div class="linenumber">5303</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;successCallback&nbsp;-&nbsp;A&nbsp;function&nbsp;which&nbsp;expects&nbsp;a&nbsp;roomName.
<a name="line5304"></a><div class="linenumber">5304</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;failureCallback&nbsp;-&nbsp;A&nbsp;function&nbsp;which&nbsp;expects&nbsp;the&nbsp;following&nbsp;arguments:&nbsp;errorCode,&nbsp;errorText,&nbsp;roomName.
<a name="line5305"></a><div class="linenumber">5305</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line5306"></a><div class="linenumber">5306</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.leaveRoom("freds_room");
<a name="line5307"></a><div class="linenumber">5307</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;easyrtc.leaveRoom("freds_room",&nbsp;function(roomName){&nbsp;console.log("left&nbsp;the&nbsp;room")},
<a name="line5308"></a><div class="linenumber">5308</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorCode,&nbsp;errorText,&nbsp;roomName){&nbsp;console.log("left&nbsp;the&nbsp;room")});
<a name="line5309"></a><div class="linenumber">5309</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5310"></a><div class="linenumber">5310</div><div style="width:2em;display:inline-block"></div>this.leaveRoom&nbsp;=&nbsp;function(roomName,&nbsp;successCallback,&nbsp;failureCallback)&nbsp;{
<a name="line5311"></a><div class="linenumber">5311</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomItem;
<a name="line5312"></a><div class="linenumber">5312</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.roomJoin[roomName])&nbsp;{
<a name="line5313"></a><div class="linenumber">5313</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!self.webSocket)&nbsp;{
<a name="line5314"></a><div class="linenumber">5314</div><div style="width:8em;display:inline-block"></div>delete&nbsp;self.roomJoin[roomName];
<a name="line5315"></a><div class="linenumber">5315</div><div style="width:6em;display:inline-block"></div>}
<a name="line5316"></a><div class="linenumber">5316</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line5317"></a><div class="linenumber">5317</div><div style="width:8em;display:inline-block"></div>roomItem&nbsp;=&nbsp;{};
<a name="line5318"></a><div class="linenumber">5318</div><div style="width:8em;display:inline-block"></div>roomItem[roomName]&nbsp;=&nbsp;{roomName:&nbsp;roomName};
<a name="line5319"></a><div class="linenumber">5319</div><div style="width:8em;display:inline-block"></div>sendSignalling(null,&nbsp;"roomLeave",&nbsp;{roomLeave:&nbsp;roomItem},
<a name="line5320"></a><div class="linenumber">5320</div><div style="width:8em;display:inline-block"></div>function(msgType,&nbsp;msgData)&nbsp;{
<a name="line5321"></a><div class="linenumber">5321</div><div style="width:10em;display:inline-block"></div>var&nbsp;roomData&nbsp;=&nbsp;msgData.roomData;
<a name="line5322"></a><div class="linenumber">5322</div><div style="width:10em;display:inline-block"></div>processRoomData(roomData);
<a name="line5323"></a><div class="linenumber">5323</div><div style="width:10em;display:inline-block"></div>if&nbsp;(successCallback)&nbsp;{
<a name="line5324"></a><div class="linenumber">5324</div><div style="width:12em;display:inline-block"></div>successCallback(roomName);
<a name="line5325"></a><div class="linenumber">5325</div><div style="width:10em;display:inline-block"></div>}
<a name="line5326"></a><div class="linenumber">5326</div><div style="width:8em;display:inline-block"></div>},
<a name="line5327"></a><div class="linenumber">5327</div><div style="width:12em;display:inline-block"></div>function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line5328"></a><div class="linenumber">5328</div><div style="width:14em;display:inline-block"></div>if&nbsp;(failureCallback)&nbsp;{
<a name="line5329"></a><div class="linenumber">5329</div><div style="width:16em;display:inline-block"></div>failureCallback(errorCode,&nbsp;errorText,&nbsp;roomName);
<a name="line5330"></a><div class="linenumber">5330</div><div style="width:14em;display:inline-block"></div>}
<a name="line5331"></a><div class="linenumber">5331</div><div style="width:12em;display:inline-block"></div>});
<a name="line5332"></a><div class="linenumber">5332</div><div style="width:6em;display:inline-block"></div>}
<a name="line5333"></a><div class="linenumber">5333</div><div style="width:4em;display:inline-block"></div>}
<a name="line5334"></a><div class="linenumber">5334</div><div style="width:2em;display:inline-block"></div>};
<a name="line5335"></a><div class="linenumber">5335</div>
<a name="line5336"></a><div class="linenumber">5336</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Get&nbsp;a&nbsp;list&nbsp;of&nbsp;the&nbsp;rooms&nbsp;you&nbsp;are&nbsp;in.&nbsp;You&nbsp;must&nbsp;be&nbsp;connected&nbsp;to&nbsp;call&nbsp;this&nbsp;function.
<a name="line5337"></a><div class="linenumber">5337</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;A&nbsp;map&nbsp;whose&nbsp;keys&nbsp;are&nbsp;the&nbsp;room&nbsp;names
<a name="line5338"></a><div class="linenumber">5338</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5339"></a><div class="linenumber">5339</div><div style="width:2em;display:inline-block"></div>this.getRoomsJoined&nbsp;=&nbsp;function()&nbsp;{
<a name="line5340"></a><div class="linenumber">5340</div><div style="width:4em;display:inline-block"></div>var&nbsp;roomsIn&nbsp;=&nbsp;{};
<a name="line5341"></a><div class="linenumber">5341</div><div style="width:4em;display:inline-block"></div>var&nbsp;key;
<a name="line5342"></a><div class="linenumber">5342</div><div style="width:4em;display:inline-block"></div>for&nbsp;(key&nbsp;in&nbsp;self.roomJoin)&nbsp;{
<a name="line5343"></a><div class="linenumber">5343</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.roomJoin.hasOwnProperty(key))&nbsp;{
<a name="line5344"></a><div class="linenumber">5344</div><div style="width:8em;display:inline-block"></div>roomsIn[key]&nbsp;=&nbsp;true;
<a name="line5345"></a><div class="linenumber">5345</div><div style="width:6em;display:inline-block"></div>}
<a name="line5346"></a><div class="linenumber">5346</div><div style="width:4em;display:inline-block"></div>}
<a name="line5347"></a><div class="linenumber">5347</div><div style="width:4em;display:inline-block"></div>return&nbsp;roomsIn;
<a name="line5348"></a><div class="linenumber">5348</div><div style="width:2em;display:inline-block"></div>};
<a name="line5349"></a><div class="linenumber">5349</div>
<a name="line5350"></a><div class="linenumber">5350</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Get&nbsp;server&nbsp;defined&nbsp;fields&nbsp;associated&nbsp;with&nbsp;a&nbsp;particular&nbsp;room.&nbsp;Only&nbsp;valid
<a name="line5351"></a><div class="linenumber">5351</div><div style="width:2em;display:inline-block"></div>*&nbsp;after&nbsp;a&nbsp;connection&nbsp;has&nbsp;been&nbsp;made.
<a name="line5352"></a><div class="linenumber">5352</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;roomName&nbsp;-&nbsp;the&nbsp;name&nbsp;of&nbsp;the&nbsp;room&nbsp;you&nbsp;want&nbsp;the&nbsp;fields&nbsp;for.
<a name="line5353"></a><div class="linenumber">5353</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;A&nbsp;dictionary&nbsp;containing&nbsp;entries&nbsp;of&nbsp;the&nbsp;form&nbsp;{key:{'fieldName':key,&nbsp;'fieldValue':value1}}&nbsp;or&nbsp;undefined
<a name="line5354"></a><div class="linenumber">5354</div><div style="width:2em;display:inline-block"></div>*&nbsp;if&nbsp;you&nbsp;are&nbsp;not&nbsp;connected&nbsp;to&nbsp;the&nbsp;room.
<a name="line5355"></a><div class="linenumber">5355</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5356"></a><div class="linenumber">5356</div><div style="width:2em;display:inline-block"></div>this.getRoomFields&nbsp;=&nbsp;function(roomName)&nbsp;{
<a name="line5357"></a><div class="linenumber">5357</div><div style="width:4em;display:inline-block"></div>return&nbsp;(!fields&nbsp;||&nbsp;!fields.rooms&nbsp;||&nbsp;!fields.rooms[roomName])&nbsp;?
<a name="line5358"></a><div class="linenumber">5358</div><div style="width:10em;display:inline-block"></div>undefined&nbsp;:&nbsp;fields.rooms[roomName];
<a name="line5359"></a><div class="linenumber">5359</div><div style="width:2em;display:inline-block"></div>};
<a name="line5360"></a><div class="linenumber">5360</div>
<a name="line5361"></a><div class="linenumber">5361</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Get&nbsp;server&nbsp;defined&nbsp;fields&nbsp;associated&nbsp;with&nbsp;the&nbsp;current&nbsp;application.&nbsp;Only&nbsp;valid
<a name="line5362"></a><div class="linenumber">5362</div><div style="width:2em;display:inline-block"></div>*&nbsp;after&nbsp;a&nbsp;connection&nbsp;has&nbsp;been&nbsp;made.
<a name="line5363"></a><div class="linenumber">5363</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;A&nbsp;dictionary&nbsp;containing&nbsp;entries&nbsp;of&nbsp;the&nbsp;form&nbsp;{key:{'fieldName':key,&nbsp;'fieldValue':value1}}
<a name="line5364"></a><div class="linenumber">5364</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5365"></a><div class="linenumber">5365</div><div style="width:2em;display:inline-block"></div>this.getApplicationFields&nbsp;=&nbsp;function()&nbsp;{
<a name="line5366"></a><div class="linenumber">5366</div><div style="width:4em;display:inline-block"></div>return&nbsp;fields.application;
<a name="line5367"></a><div class="linenumber">5367</div><div style="width:2em;display:inline-block"></div>};
<a name="line5368"></a><div class="linenumber">5368</div>
<a name="line5369"></a><div class="linenumber">5369</div><div style="width:2em;display:inline-block"></div>/**&nbsp;Get&nbsp;server&nbsp;defined&nbsp;fields&nbsp;associated&nbsp;with&nbsp;the&nbsp;connection.&nbsp;Only&nbsp;valid
<a name="line5370"></a><div class="linenumber">5370</div><div style="width:2em;display:inline-block"></div>*&nbsp;after&nbsp;a&nbsp;connection&nbsp;has&nbsp;been&nbsp;made.
<a name="line5371"></a><div class="linenumber">5371</div><div style="width:2em;display:inline-block"></div>*&nbsp;@returns&nbsp;{Object}&nbsp;A&nbsp;dictionary&nbsp;containing&nbsp;entries&nbsp;of&nbsp;the&nbsp;form&nbsp;{key:{'fieldName':key,&nbsp;'fieldValue':value1}}
<a name="line5372"></a><div class="linenumber">5372</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5373"></a><div class="linenumber">5373</div><div style="width:2em;display:inline-block"></div>this.getConnectionFields&nbsp;=&nbsp;function()&nbsp;{
<a name="line5374"></a><div class="linenumber">5374</div><div style="width:4em;display:inline-block"></div>return&nbsp;fields.connection;
<a name="line5375"></a><div class="linenumber">5375</div><div style="width:2em;display:inline-block"></div>};
<a name="line5376"></a><div class="linenumber">5376</div>
<a name="line5377"></a><div class="linenumber">5377</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5378"></a><div class="linenumber">5378</div><div style="width:2em;display:inline-block"></div>*&nbsp;Supply&nbsp;a&nbsp;socket.io&nbsp;connection&nbsp;that&nbsp;will&nbsp;be&nbsp;used&nbsp;instead&nbsp;of&nbsp;allocating&nbsp;a&nbsp;new&nbsp;socket.
<a name="line5379"></a><div class="linenumber">5379</div><div style="width:2em;display:inline-block"></div>*&nbsp;The&nbsp;expected&nbsp;usage&nbsp;is&nbsp;that&nbsp;you&nbsp;allocate&nbsp;a&nbsp;websocket,&nbsp;assign&nbsp;options&nbsp;to&nbsp;it,&nbsp;call
<a name="line5380"></a><div class="linenumber">5380</div><div style="width:2em;display:inline-block"></div>*&nbsp;easyrtc.useThisSocketConnection,&nbsp;followed&nbsp;by&nbsp;easyrtc.connect&nbsp;or&nbsp;easyrtc.easyApp.&nbsp;Easyrtc&nbsp;will&nbsp;not&nbsp;attempt&nbsp;to
<a name="line5381"></a><div class="linenumber">5381</div><div style="width:2em;display:inline-block"></div>*&nbsp;close&nbsp;sockets&nbsp;that&nbsp;were&nbsp;supplied&nbsp;with&nbsp;easyrtc.useThisSocketConnection.
<a name="line5382"></a><div class="linenumber">5382</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Object}&nbsp;alreadyAllocatedSocketIo&nbsp;A&nbsp;value&nbsp;allocated&nbsp;with&nbsp;the&nbsp;connect&nbsp;method&nbsp;of&nbsp;socket.io.
<a name="line5383"></a><div class="linenumber">5383</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5384"></a><div class="linenumber">5384</div><div style="width:2em;display:inline-block"></div>this.useThisSocketConnection&nbsp;=&nbsp;function(alreadyAllocatedSocketIo)&nbsp;{
<a name="line5385"></a><div class="linenumber">5385</div><div style="width:4em;display:inline-block"></div>preallocatedSocketIo&nbsp;=&nbsp;alreadyAllocatedSocketIo;
<a name="line5386"></a><div class="linenumber">5386</div><div style="width:2em;display:inline-block"></div>};
<a name="line5387"></a><div class="linenumber">5387</div>
<a name="line5388"></a><div class="linenumber">5388</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line5389"></a><div class="linenumber">5389</div><div style="width:2em;display:inline-block"></div>function&nbsp;processToken(msg)&nbsp;{
<a name="line5390"></a><div class="linenumber">5390</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgData&nbsp;=&nbsp;msg.msgData;
<a name="line5391"></a><div class="linenumber">5391</div><div style="width:4em;display:inline-block"></div>logDebug("entered&nbsp;process&nbsp;token");
<a name="line5392"></a><div class="linenumber">5392</div>
<a name="line5393"></a><div class="linenumber">5393</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msgData.easyrtcid)&nbsp;{
<a name="line5394"></a><div class="linenumber">5394</div><div style="width:6em;display:inline-block"></div>self.myEasyrtcid&nbsp;=&nbsp;msgData.easyrtcid;
<a name="line5395"></a><div class="linenumber">5395</div><div style="width:4em;display:inline-block"></div>}
<a name="line5396"></a><div class="linenumber">5396</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msgData.field)&nbsp;{
<a name="line5397"></a><div class="linenumber">5397</div><div style="width:6em;display:inline-block"></div>fields.connection&nbsp;=&nbsp;msgData.field;
<a name="line5398"></a><div class="linenumber">5398</div><div style="width:4em;display:inline-block"></div>}
<a name="line5399"></a><div class="linenumber">5399</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msgData.iceConfig)&nbsp;{
<a name="line5400"></a><div class="linenumber">5400</div><div style="width:6em;display:inline-block"></div>processIceConfig(msgData.iceConfig);
<a name="line5401"></a><div class="linenumber">5401</div><div style="width:4em;display:inline-block"></div>}
<a name="line5402"></a><div class="linenumber">5402</div>
<a name="line5403"></a><div class="linenumber">5403</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msgData.sessionData)&nbsp;{
<a name="line5404"></a><div class="linenumber">5404</div><div style="width:6em;display:inline-block"></div>processSessionData(msgData.sessionData);
<a name="line5405"></a><div class="linenumber">5405</div><div style="width:4em;display:inline-block"></div>}
<a name="line5406"></a><div class="linenumber">5406</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msgData.roomData)&nbsp;{
<a name="line5407"></a><div class="linenumber">5407</div><div style="width:6em;display:inline-block"></div>processRoomData(msgData.roomData);
<a name="line5408"></a><div class="linenumber">5408</div><div style="width:4em;display:inline-block"></div>}
<a name="line5409"></a><div class="linenumber">5409</div><div style="width:4em;display:inline-block"></div>if&nbsp;(msgData.application.field)&nbsp;{
<a name="line5410"></a><div class="linenumber">5410</div><div style="width:6em;display:inline-block"></div>fields.application&nbsp;=&nbsp;msgData.application.field;
<a name="line5411"></a><div class="linenumber">5411</div><div style="width:4em;display:inline-block"></div>}
<a name="line5412"></a><div class="linenumber">5412</div><div style="width:2em;display:inline-block"></div>}
<a name="line5413"></a><div class="linenumber">5413</div>
<a name="line5414"></a><div class="linenumber">5414</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line5415"></a><div class="linenumber">5415</div><div style="width:2em;display:inline-block"></div>function&nbsp;sendAuthenticate(successCallback,&nbsp;errorCallback)&nbsp;{
<a name="line5416"></a><div class="linenumber">5416</div><div style="width:4em;display:inline-block"></div>//
<a name="line5417"></a><div class="linenumber">5417</div><div style="width:4em;display:inline-block"></div>//&nbsp;find&nbsp;our&nbsp;easyrtcsid
<a name="line5418"></a><div class="linenumber">5418</div><div style="width:4em;display:inline-block"></div>//
<a name="line5419"></a><div class="linenumber">5419</div><div style="width:4em;display:inline-block"></div>var&nbsp;cookies,&nbsp;target,&nbsp;i;
<a name="line5420"></a><div class="linenumber">5420</div><div style="width:4em;display:inline-block"></div>var&nbsp;easyrtcsid&nbsp;=&nbsp;null;
<a name="line5421"></a><div class="linenumber">5421</div>
<a name="line5422"></a><div class="linenumber">5422</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.cookieId&nbsp;&amp;&amp;&nbsp;document.cookie)&nbsp;{
<a name="line5423"></a><div class="linenumber">5423</div><div style="width:6em;display:inline-block"></div>cookies&nbsp;=&nbsp;document.cookie.split(/[;&nbsp;]/g);
<a name="line5424"></a><div class="linenumber">5424</div><div style="width:6em;display:inline-block"></div>target&nbsp;=&nbsp;self.cookieId&nbsp;+&nbsp;"=";
<a name="line5425"></a><div class="linenumber">5425</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;cookies.length;&nbsp;i++)&nbsp;{
<a name="line5426"></a><div class="linenumber">5426</div><div style="width:8em;display:inline-block"></div>if&nbsp;(cookies[i].indexOf(target)&nbsp;===&nbsp;0)&nbsp;{
<a name="line5427"></a><div class="linenumber">5427</div><div style="width:10em;display:inline-block"></div>easyrtcsid&nbsp;=&nbsp;cookies[i].substring(target.length);
<a name="line5428"></a><div class="linenumber">5428</div><div style="width:8em;display:inline-block"></div>}
<a name="line5429"></a><div class="linenumber">5429</div><div style="width:6em;display:inline-block"></div>}
<a name="line5430"></a><div class="linenumber">5430</div><div style="width:4em;display:inline-block"></div>}
<a name="line5431"></a><div class="linenumber">5431</div>
<a name="line5432"></a><div class="linenumber">5432</div><div style="width:4em;display:inline-block"></div>var&nbsp;msgData&nbsp;=&nbsp;{
<a name="line5433"></a><div class="linenumber">5433</div><div style="width:6em;display:inline-block"></div>apiVersion:&nbsp;self.apiVersion,
<a name="line5434"></a><div class="linenumber">5434</div><div style="width:6em;display:inline-block"></div>applicationName:&nbsp;self.applicationName,
<a name="line5435"></a><div class="linenumber">5435</div><div style="width:6em;display:inline-block"></div>setUserCfg:&nbsp;collectConfigurationInfo(true)
<a name="line5436"></a><div class="linenumber">5436</div><div style="width:4em;display:inline-block"></div>};
<a name="line5437"></a><div class="linenumber">5437</div>
<a name="line5438"></a><div class="linenumber">5438</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!self.roomJoin)&nbsp;{
<a name="line5439"></a><div class="linenumber">5439</div><div style="width:6em;display:inline-block"></div>self.roomJoin&nbsp;=&nbsp;{};
<a name="line5440"></a><div class="linenumber">5440</div><div style="width:4em;display:inline-block"></div>}
<a name="line5441"></a><div class="linenumber">5441</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.presenceShow)&nbsp;{
<a name="line5442"></a><div class="linenumber">5442</div><div style="width:6em;display:inline-block"></div>msgData.setPresence&nbsp;=&nbsp;{
<a name="line5443"></a><div class="linenumber">5443</div><div style="width:8em;display:inline-block"></div>show:&nbsp;self.presenceShow,
<a name="line5444"></a><div class="linenumber">5444</div><div style="width:8em;display:inline-block"></div>status:&nbsp;self.presenceStatus
<a name="line5445"></a><div class="linenumber">5445</div><div style="width:6em;display:inline-block"></div>};
<a name="line5446"></a><div class="linenumber">5446</div><div style="width:4em;display:inline-block"></div>}
<a name="line5447"></a><div class="linenumber">5447</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.username)&nbsp;{
<a name="line5448"></a><div class="linenumber">5448</div><div style="width:6em;display:inline-block"></div>msgData.username&nbsp;=&nbsp;self.username;
<a name="line5449"></a><div class="linenumber">5449</div><div style="width:4em;display:inline-block"></div>}
<a name="line5450"></a><div class="linenumber">5450</div><div style="width:4em;display:inline-block"></div>if&nbsp;(self.roomJoin&nbsp;&amp;&amp;&nbsp;!isEmptyObj(self.roomJoin))&nbsp;{
<a name="line5451"></a><div class="linenumber">5451</div><div style="width:6em;display:inline-block"></div>msgData.roomJoin&nbsp;=&nbsp;self.roomJoin;
<a name="line5452"></a><div class="linenumber">5452</div><div style="width:4em;display:inline-block"></div>}
<a name="line5453"></a><div class="linenumber">5453</div><div style="width:4em;display:inline-block"></div>if&nbsp;(easyrtcsid)&nbsp;{
<a name="line5454"></a><div class="linenumber">5454</div><div style="width:6em;display:inline-block"></div>msgData.easyrtcsid&nbsp;=&nbsp;easyrtcsid;
<a name="line5455"></a><div class="linenumber">5455</div><div style="width:4em;display:inline-block"></div>}
<a name="line5456"></a><div class="linenumber">5456</div><div style="width:4em;display:inline-block"></div>if&nbsp;(credential)&nbsp;{
<a name="line5457"></a><div class="linenumber">5457</div><div style="width:6em;display:inline-block"></div>msgData.credential&nbsp;=&nbsp;credential;
<a name="line5458"></a><div class="linenumber">5458</div><div style="width:4em;display:inline-block"></div>}
<a name="line5459"></a><div class="linenumber">5459</div>
<a name="line5460"></a><div class="linenumber">5460</div><div style="width:4em;display:inline-block"></div>self.webSocket.json.emit(
<a name="line5461"></a><div class="linenumber">5461</div><div style="width:6em;display:inline-block"></div>"easyrtcAuth",
<a name="line5462"></a><div class="linenumber">5462</div><div style="width:6em;display:inline-block"></div>{
<a name="line5463"></a><div class="linenumber">5463</div><div style="width:8em;display:inline-block"></div>msgType:&nbsp;"authenticate",
<a name="line5464"></a><div class="linenumber">5464</div><div style="width:8em;display:inline-block"></div>msgData:&nbsp;msgData
<a name="line5465"></a><div class="linenumber">5465</div><div style="width:6em;display:inline-block"></div>},
<a name="line5466"></a><div class="linenumber">5466</div><div style="width:6em;display:inline-block"></div>function(msg)&nbsp;{
<a name="line5467"></a><div class="linenumber">5467</div><div style="width:8em;display:inline-block"></div>var&nbsp;room;
<a name="line5468"></a><div class="linenumber">5468</div><div style="width:8em;display:inline-block"></div>if&nbsp;(msg.msgType&nbsp;===&nbsp;"error")&nbsp;{
<a name="line5469"></a><div class="linenumber">5469</div><div style="width:10em;display:inline-block"></div>errorCallback(msg.msgData.errorCode,&nbsp;msg.msgData.errorText);
<a name="line5470"></a><div class="linenumber">5470</div><div style="width:10em;display:inline-block"></div>self.roomJoin&nbsp;=&nbsp;{};
<a name="line5471"></a><div class="linenumber">5471</div><div style="width:8em;display:inline-block"></div>}
<a name="line5472"></a><div class="linenumber">5472</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line5473"></a><div class="linenumber">5473</div><div style="width:10em;display:inline-block"></div>processToken(msg);
<a name="line5474"></a><div class="linenumber">5474</div><div style="width:10em;display:inline-block"></div>if&nbsp;(self._roomApiFields)&nbsp;{
<a name="line5475"></a><div class="linenumber">5475</div><div style="width:12em;display:inline-block"></div>for&nbsp;(room&nbsp;in&nbsp;self._roomApiFields)&nbsp;{
<a name="line5476"></a><div class="linenumber">5476</div><div style="width:14em;display:inline-block"></div>if&nbsp;(self._roomApiFields.hasOwnProperty(room))&nbsp;{
<a name="line5477"></a><div class="linenumber">5477</div><div style="width:16em;display:inline-block"></div>enqueueSendRoomApi(room);
<a name="line5478"></a><div class="linenumber">5478</div><div style="width:14em;display:inline-block"></div>}
<a name="line5479"></a><div class="linenumber">5479</div><div style="width:12em;display:inline-block"></div>}
<a name="line5480"></a><div class="linenumber">5480</div><div style="width:10em;display:inline-block"></div>}
<a name="line5481"></a><div class="linenumber">5481</div>
<a name="line5482"></a><div class="linenumber">5482</div><div style="width:10em;display:inline-block"></div>if&nbsp;(successCallback)&nbsp;{
<a name="line5483"></a><div class="linenumber">5483</div><div style="width:12em;display:inline-block"></div>successCallback(self.myEasyrtcid);
<a name="line5484"></a><div class="linenumber">5484</div><div style="width:10em;display:inline-block"></div>}
<a name="line5485"></a><div class="linenumber">5485</div><div style="width:8em;display:inline-block"></div>}
<a name="line5486"></a><div class="linenumber">5486</div><div style="width:6em;display:inline-block"></div>}
<a name="line5487"></a><div class="linenumber">5487</div><div style="width:4em;display:inline-block"></div>);
<a name="line5488"></a><div class="linenumber">5488</div><div style="width:2em;display:inline-block"></div>}
<a name="line5489"></a><div class="linenumber">5489</div>
<a name="line5490"></a><div class="linenumber">5490</div><div style="width:2em;display:inline-block"></div>/**&nbsp;@private&nbsp;*/
<a name="line5491"></a><div class="linenumber">5491</div><div style="width:2em;display:inline-block"></div>function&nbsp;connectToWSServer(successCallback,&nbsp;errorCallback)&nbsp;{
<a name="line5492"></a><div class="linenumber">5492</div><div style="width:4em;display:inline-block"></div>var&nbsp;i;
<a name="line5493"></a><div class="linenumber">5493</div><div style="width:4em;display:inline-block"></div>if&nbsp;(preallocatedSocketIo)&nbsp;{
<a name="line5494"></a><div class="linenumber">5494</div><div style="width:6em;display:inline-block"></div>self.webSocket&nbsp;=&nbsp;preallocatedSocketIo;
<a name="line5495"></a><div class="linenumber">5495</div><div style="width:4em;display:inline-block"></div>}
<a name="line5496"></a><div class="linenumber">5496</div><div style="width:4em;display:inline-block"></div>else&nbsp;if&nbsp;(!self.webSocket)&nbsp;{
<a name="line5497"></a><div class="linenumber">5497</div><div style="width:6em;display:inline-block"></div>try&nbsp;{
<a name="line5498"></a><div class="linenumber">5498</div><div style="width:7em;display:inline-block"></div>self.webSocket&nbsp;=&nbsp;io.connect(serverPath,&nbsp;connectionOptions);
<a name="line5499"></a><div class="linenumber">5499</div>
<a name="line5500"></a><div class="linenumber">5500</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!self.webSocket)&nbsp;{
<a name="line5501"></a><div class="linenumber">5501</div><div style="width:10em;display:inline-block"></div>throw&nbsp;"io.connect&nbsp;failed";
<a name="line5502"></a><div class="linenumber">5502</div><div style="width:8em;display:inline-block"></div>}
<a name="line5503"></a><div class="linenumber">5503</div>
<a name="line5504"></a><div class="linenumber">5504</div><div style="width:6em;display:inline-block"></div>}&nbsp;catch(socketErr)&nbsp;{
<a name="line5505"></a><div class="linenumber">5505</div><div style="width:8em;display:inline-block"></div>self.webSocket&nbsp;=&nbsp;0;
<a name="line5506"></a><div class="linenumber">5506</div><div style="width:8em;display:inline-block"></div>errorCallback(&nbsp;self.errCodes.SYSTEM_ERROR,&nbsp;socketErr.toString());
<a name="line5507"></a><div class="linenumber">5507</div>
<a name="line5508"></a><div class="linenumber">5508</div><div style="width:7em;display:inline-block"></div>return;
<a name="line5509"></a><div class="linenumber">5509</div><div style="width:6em;display:inline-block"></div>}
<a name="line5510"></a><div class="linenumber">5510</div><div style="width:4em;display:inline-block"></div>}
<a name="line5511"></a><div class="linenumber">5511</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line5512"></a><div class="linenumber">5512</div><div style="width:6em;display:inline-block"></div>for&nbsp;(i&nbsp;in&nbsp;self.websocketListeners)&nbsp;{
<a name="line5513"></a><div class="linenumber">5513</div><div style="width:8em;display:inline-block"></div>if&nbsp;(!self.websocketListeners.hasOwnProperty(i))&nbsp;{
<a name="line5514"></a><div class="linenumber">5514</div><div style="width:10em;display:inline-block"></div>continue;
<a name="line5515"></a><div class="linenumber">5515</div><div style="width:8em;display:inline-block"></div>}
<a name="line5516"></a><div class="linenumber">5516</div><div style="width:8em;display:inline-block"></div>self.webSocket.removeEventListener(self.websocketListeners[i].event,
<a name="line5517"></a><div class="linenumber">5517</div><div style="width:12em;display:inline-block"></div>self.websocketListeners[i].handler);
<a name="line5518"></a><div class="linenumber">5518</div><div style="width:6em;display:inline-block"></div>}
<a name="line5519"></a><div class="linenumber">5519</div><div style="width:4em;display:inline-block"></div>}
<a name="line5520"></a><div class="linenumber">5520</div>
<a name="line5521"></a><div class="linenumber">5521</div><div style="width:4em;display:inline-block"></div>self.websocketListeners&nbsp;=&nbsp;[];
<a name="line5522"></a><div class="linenumber">5522</div>
<a name="line5523"></a><div class="linenumber">5523</div><div style="width:4em;display:inline-block"></div>function&nbsp;addSocketListener(event,&nbsp;handler)&nbsp;{
<a name="line5524"></a><div class="linenumber">5524</div><div style="width:6em;display:inline-block"></div>self.webSocket.on(event,&nbsp;handler);
<a name="line5525"></a><div class="linenumber">5525</div><div style="width:6em;display:inline-block"></div>self.websocketListeners.push({event:&nbsp;event,&nbsp;handler:&nbsp;handler});
<a name="line5526"></a><div class="linenumber">5526</div><div style="width:4em;display:inline-block"></div>}
<a name="line5527"></a><div class="linenumber">5527</div>
<a name="line5528"></a><div class="linenumber">5528</div><div style="width:4em;display:inline-block"></div>addSocketListener("close",&nbsp;function(event)&nbsp;{
<a name="line5529"></a><div class="linenumber">5529</div><div style="width:6em;display:inline-block"></div>logDebug("the&nbsp;web&nbsp;socket&nbsp;closed");
<a name="line5530"></a><div class="linenumber">5530</div><div style="width:4em;display:inline-block"></div>});
<a name="line5531"></a><div class="linenumber">5531</div>
<a name="line5532"></a><div class="linenumber">5532</div><div style="width:4em;display:inline-block"></div>addSocketListener('error',&nbsp;function(event)&nbsp;{
<a name="line5533"></a><div class="linenumber">5533</div><div style="width:6em;display:inline-block"></div>function&nbsp;handleErrorEvent()&nbsp;{
<a name="line5534"></a><div class="linenumber">5534</div><div style="width:8em;display:inline-block"></div>if&nbsp;(self.myEasyrtcid)&nbsp;{
<a name="line5535"></a><div class="linenumber">5535</div><div style="width:10em;display:inline-block"></div>//
<a name="line5536"></a><div class="linenumber">5536</div><div style="width:10em;display:inline-block"></div>//&nbsp;socket.io&nbsp;version&nbsp;1&nbsp;got&nbsp;rid&nbsp;of&nbsp;the&nbsp;socket&nbsp;member,&nbsp;moving&nbsp;everything&nbsp;up&nbsp;one&nbsp;level.
<a name="line5537"></a><div class="linenumber">5537</div><div style="width:10em;display:inline-block"></div>//
<a name="line5538"></a><div class="linenumber">5538</div><div style="width:10em;display:inline-block"></div>if&nbsp;(isSocketConnected(self.webSocket))&nbsp;{
<a name="line5539"></a><div class="linenumber">5539</div><div style="width:12em;display:inline-block"></div>self.showError(self.errCodes.SIGNAL_ERR,&nbsp;self.getConstantString("miscSignalError"));
<a name="line5540"></a><div class="linenumber">5540</div><div style="width:10em;display:inline-block"></div>}
<a name="line5541"></a><div class="linenumber">5541</div><div style="width:10em;display:inline-block"></div>else&nbsp;{
<a name="line5542"></a><div class="linenumber">5542</div><div style="width:12em;display:inline-block"></div>/*&nbsp;socket&nbsp;server&nbsp;went&nbsp;down.&nbsp;this&nbsp;will&nbsp;generate&nbsp;a&nbsp;'disconnect'&nbsp;event&nbsp;as&nbsp;well,&nbsp;so&nbsp;skip&nbsp;this&nbsp;event&nbsp;*/
<a name="line5543"></a><div class="linenumber">5543</div><div style="width:12em;display:inline-block"></div>errorCallback(self.errCodes.CONNECT_ERR,&nbsp;self.getConstantString("noServer"));
<a name="line5544"></a><div class="linenumber">5544</div><div style="width:10em;display:inline-block"></div>}
<a name="line5545"></a><div class="linenumber">5545</div><div style="width:8em;display:inline-block"></div>}
<a name="line5546"></a><div class="linenumber">5546</div><div style="width:8em;display:inline-block"></div>else&nbsp;{
<a name="line5547"></a><div class="linenumber">5547</div><div style="width:10em;display:inline-block"></div>errorCallback(self.errCodes.CONNECT_ERR,&nbsp;self.getConstantString("noServer"));
<a name="line5548"></a><div class="linenumber">5548</div><div style="width:8em;display:inline-block"></div>}
<a name="line5549"></a><div class="linenumber">5549</div><div style="width:6em;display:inline-block"></div>}
<a name="line5550"></a><div class="linenumber">5550</div><div style="width:6em;display:inline-block"></div>handleErrorEvent();
<a name="line5551"></a><div class="linenumber">5551</div><div style="width:4em;display:inline-block"></div>});
<a name="line5552"></a><div class="linenumber">5552</div>
<a name="line5553"></a><div class="linenumber">5553</div><div style="width:4em;display:inline-block"></div>function&nbsp;connectHandler(event)&nbsp;{
<a name="line5554"></a><div class="linenumber">5554</div><div style="width:6em;display:inline-block"></div>self.webSocketConnected&nbsp;=&nbsp;true;
<a name="line5555"></a><div class="linenumber">5555</div><div style="width:6em;display:inline-block"></div>if&nbsp;(!self.webSocket)&nbsp;{
<a name="line5556"></a><div class="linenumber">5556</div><div style="width:8em;display:inline-block"></div>self.showError(self.errCodes.CONNECT_ERR,&nbsp;self.getConstantString("badsocket"));
<a name="line5557"></a><div class="linenumber">5557</div><div style="width:6em;display:inline-block"></div>}
<a name="line5558"></a><div class="linenumber">5558</div>
<a name="line5559"></a><div class="linenumber">5559</div><div style="width:6em;display:inline-block"></div>logDebug("saw&nbsp;socket-server&nbsp;onconnect&nbsp;event");
<a name="line5560"></a><div class="linenumber">5560</div>
<a name="line5561"></a><div class="linenumber">5561</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.webSocketConnected)&nbsp;{
<a name="line5562"></a><div class="linenumber">5562</div><div style="width:8em;display:inline-block"></div>sendAuthenticate(successCallback,&nbsp;errorCallback);
<a name="line5563"></a><div class="linenumber">5563</div><div style="width:6em;display:inline-block"></div>}
<a name="line5564"></a><div class="linenumber">5564</div><div style="width:6em;display:inline-block"></div>else&nbsp;{
<a name="line5565"></a><div class="linenumber">5565</div><div style="width:8em;display:inline-block"></div>errorCallback(self.errCodes.SIGNAL_ERR,&nbsp;self.getConstantString("icf"));
<a name="line5566"></a><div class="linenumber">5566</div><div style="width:6em;display:inline-block"></div>}
<a name="line5567"></a><div class="linenumber">5567</div><div style="width:4em;display:inline-block"></div>}
<a name="line5568"></a><div class="linenumber">5568</div>
<a name="line5569"></a><div class="linenumber">5569</div><div style="width:4em;display:inline-block"></div>if&nbsp;(isSocketConnected(preallocatedSocketIo))&nbsp;{
<a name="line5570"></a><div class="linenumber">5570</div><div style="width:6em;display:inline-block"></div>connectHandler(null);
<a name="line5571"></a><div class="linenumber">5571</div><div style="width:4em;display:inline-block"></div>}
<a name="line5572"></a><div class="linenumber">5572</div><div style="width:4em;display:inline-block"></div>else&nbsp;{
<a name="line5573"></a><div class="linenumber">5573</div><div style="width:6em;display:inline-block"></div>addSocketListener("connect",&nbsp;connectHandler);
<a name="line5574"></a><div class="linenumber">5574</div><div style="width:4em;display:inline-block"></div>}
<a name="line5575"></a><div class="linenumber">5575</div>
<a name="line5576"></a><div class="linenumber">5576</div><div style="width:4em;display:inline-block"></div>addSocketListener("easyrtcMsg",&nbsp;onChannelMsg);
<a name="line5577"></a><div class="linenumber">5577</div><div style="width:4em;display:inline-block"></div>addSocketListener("easyrtcCmd",&nbsp;onChannelCmd);
<a name="line5578"></a><div class="linenumber">5578</div><div style="width:4em;display:inline-block"></div>addSocketListener("disconnect",&nbsp;function(/*&nbsp;code,&nbsp;reason,&nbsp;wasClean&nbsp;*/)&nbsp;{
<a name="line5579"></a><div class="linenumber">5579</div>
<a name="line5580"></a><div class="linenumber">5580</div><div style="width:6em;display:inline-block"></div>self.webSocketConnected&nbsp;=&nbsp;false;
<a name="line5581"></a><div class="linenumber">5581</div><div style="width:6em;display:inline-block"></div>updateConfigurationInfo&nbsp;=&nbsp;function()&nbsp;{};&nbsp;//&nbsp;dummy&nbsp;update&nbsp;function
<a name="line5582"></a><div class="linenumber">5582</div><div style="width:6em;display:inline-block"></div>oldConfig&nbsp;=&nbsp;{};
<a name="line5583"></a><div class="linenumber">5583</div><div style="width:6em;display:inline-block"></div>disconnectBody();
<a name="line5584"></a><div class="linenumber">5584</div>
<a name="line5585"></a><div class="linenumber">5585</div><div style="width:6em;display:inline-block"></div>if&nbsp;(self.disconnectListener)&nbsp;{
<a name="line5586"></a><div class="linenumber">5586</div><div style="width:8em;display:inline-block"></div>self.disconnectListener();
<a name="line5587"></a><div class="linenumber">5587</div><div style="width:6em;display:inline-block"></div>}
<a name="line5588"></a><div class="linenumber">5588</div><div style="width:4em;display:inline-block"></div>});
<a name="line5589"></a><div class="linenumber">5589</div><div style="width:2em;display:inline-block"></div>}
<a name="line5590"></a><div class="linenumber">5590</div>
<a name="line5591"></a><div class="linenumber">5591</div><div style="width:2em;display:inline-block"></div>/**
<a name="line5592"></a><div class="linenumber">5592</div><div style="width:2em;display:inline-block"></div>*&nbsp;Connects&nbsp;to&nbsp;the&nbsp;EasyRTC&nbsp;signaling&nbsp;server.&nbsp;You&nbsp;must&nbsp;connect&nbsp;before&nbsp;trying&nbsp;to
<a name="line5593"></a><div class="linenumber">5593</div><div style="width:2em;display:inline-block"></div>*&nbsp;call&nbsp;other&nbsp;users.
<a name="line5594"></a><div class="linenumber">5594</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{String}&nbsp;applicationName&nbsp;is&nbsp;a&nbsp;string&nbsp;that&nbsp;identifies&nbsp;the&nbsp;application&nbsp;so&nbsp;that&nbsp;different&nbsp;applications&nbsp;can&nbsp;have&nbsp;different
<a name="line5595"></a><div class="linenumber">5595</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lists&nbsp;of&nbsp;users.&nbsp;Note&nbsp;that&nbsp;the&nbsp;server&nbsp;configuration&nbsp;specifies&nbsp;a&nbsp;regular&nbsp;expression&nbsp;that&nbsp;is&nbsp;used&nbsp;to&nbsp;check&nbsp;application&nbsp;names
<a name="line5596"></a><div class="linenumber">5596</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;validity.&nbsp;The&nbsp;default&nbsp;pattern&nbsp;is&nbsp;that&nbsp;of&nbsp;an&nbsp;identifier,&nbsp;spaces&nbsp;are&nbsp;not&nbsp;allowed.
<a name="line5597"></a><div class="linenumber">5597</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;successCallback&nbsp;(easyrtcId,&nbsp;roomOwner)&nbsp;-&nbsp;is&nbsp;called&nbsp;on&nbsp;successful&nbsp;connect.&nbsp;easyrtcId&nbsp;is&nbsp;the
<a name="line5598"></a><div class="linenumber">5598</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;unique&nbsp;name&nbsp;that&nbsp;the&nbsp;client&nbsp;is&nbsp;known&nbsp;to&nbsp;the&nbsp;server&nbsp;by.&nbsp;A&nbsp;client&nbsp;usually&nbsp;only&nbsp;needs&nbsp;it's&nbsp;own&nbsp;easyrtcId&nbsp;for&nbsp;debugging&nbsp;purposes.
<a name="line5599"></a><div class="linenumber">5599</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;roomOwner&nbsp;is&nbsp;true&nbsp;if&nbsp;the&nbsp;user&nbsp;is&nbsp;the&nbsp;owner&nbsp;of&nbsp;a&nbsp;room.&nbsp;It's&nbsp;value&nbsp;is&nbsp;random&nbsp;if&nbsp;the&nbsp;user&nbsp;is&nbsp;in&nbsp;multiple&nbsp;rooms.
<a name="line5600"></a><div class="linenumber">5600</div><div style="width:2em;display:inline-block"></div>*&nbsp;@param&nbsp;{Function}&nbsp;errorCallback&nbsp;(errorCode,&nbsp;errorText)&nbsp;-&nbsp;is&nbsp;called&nbsp;on&nbsp;unsuccessful&nbsp;connect.&nbsp;if&nbsp;null,&nbsp;an&nbsp;alert&nbsp;is&nbsp;called&nbsp;instead.
<a name="line5601"></a><div class="linenumber">5601</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;The&nbsp;errorCode&nbsp;takes&nbsp;it's&nbsp;value&nbsp;from&nbsp;easyrtc.errCodes.
<a name="line5602"></a><div class="linenumber">5602</div><div style="width:2em;display:inline-block"></div>*&nbsp;@example
<a name="line5603"></a><div class="linenumber">5603</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;easyrtc.connect("my_chat_app",
<a name="line5604"></a><div class="linenumber">5604</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(easyrtcid,&nbsp;roomOwner){
<a name="line5605"></a><div class="linenumber">5605</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;roomOwner){&nbsp;console.log("I'm&nbsp;the&nbsp;room&nbsp;owner");&nbsp;}
<a name="line5606"></a><div class="linenumber">5606</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("my&nbsp;id&nbsp;is&nbsp;"&nbsp;+&nbsp;easyrtcid);
<a name="line5607"></a><div class="linenumber">5607</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},
<a name="line5608"></a><div class="linenumber">5608</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(errorText){
<a name="line5609"></a><div class="linenumber">5609</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log("failed&nbsp;to&nbsp;connect&nbsp;",&nbsp;erFrText);
<a name="line5610"></a><div class="linenumber">5610</div><div style="width:2em;display:inline-block"></div>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
<a name="line5611"></a><div class="linenumber">5611</div><div style="width:2em;display:inline-block"></div>*/
<a name="line5612"></a><div class="linenumber">5612</div><div style="width:2em;display:inline-block"></div>this.connect&nbsp;=&nbsp;function(applicationName,&nbsp;successCallback,&nbsp;errorCallback)&nbsp;{
<a name="line5613"></a><div class="linenumber">5613</div>
<a name="line5614"></a><div class="linenumber">5614</div><div style="width:4em;display:inline-block"></div>//&nbsp;Detect&nbsp;invalid&nbsp;or&nbsp;missing&nbsp;socket.io
<a name="line5615"></a><div class="linenumber">5615</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!io)&nbsp;{
<a name="line5616"></a><div class="linenumber">5616</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Your&nbsp;HTML&nbsp;has&nbsp;not&nbsp;included&nbsp;the&nbsp;socket.io.js&nbsp;library");
<a name="line5617"></a><div class="linenumber">5617</div><div style="width:4em;display:inline-block"></div>}
<a name="line5618"></a><div class="linenumber">5618</div>
<a name="line5619"></a><div class="linenumber">5619</div><div style="width:4em;display:inline-block"></div>if&nbsp;(!preallocatedSocketIo&nbsp;&amp;&amp;&nbsp;self.webSocket)&nbsp;{
<a name="line5620"></a><div class="linenumber">5620</div><div style="width:6em;display:inline-block"></div>self.showError(self.errCodes.DEVELOPER_ERR,&nbsp;"Attempt&nbsp;to&nbsp;connect&nbsp;when&nbsp;already&nbsp;connected&nbsp;to&nbsp;socket&nbsp;server");
<a name="line5621"></a><div class="linenumber">5621</div><div style="width:6em;display:inline-block"></div>return;
<a name="line5622"></a><div class="linenumber">5622</div><div style="width:4em;display:inline-block"></div>}
<a name="line5623"></a><div class="linenumber">5623</div><div style="width:4em;display:inline-block"></div>pc_config&nbsp;=&nbsp;{};
<a name="line5624"></a><div class="linenumber">5624</div><div style="width:4em;display:inline-block"></div>closedChannel&nbsp;=&nbsp;null;
<a name="line5625"></a><div class="linenumber">5625</div><div style="width:4em;display:inline-block"></div>oldConfig&nbsp;=&nbsp;{};&nbsp;//&nbsp;used&nbsp;internally&nbsp;by&nbsp;updateConfiguration
<a name="line5626"></a><div class="linenumber">5626</div><div style="width:4em;display:inline-block"></div>queuedMessages&nbsp;=&nbsp;{};
<a name="line5627"></a><div class="linenumber">5627</div><div style="width:4em;display:inline-block"></div>self.applicationName&nbsp;=&nbsp;applicationName;
<a name="line5628"></a><div class="linenumber">5628</div><div style="width:4em;display:inline-block"></div>fields&nbsp;=&nbsp;{
<a name="line5629"></a><div class="linenumber">5629</div><div style="width:6em;display:inline-block"></div>rooms:&nbsp;{},
<a name="line5630"></a><div class="linenumber">5630</div><div style="width:6em;display:inline-block"></div>application:&nbsp;{},
<a name="line5631"></a><div class="linenumber">5631</div><div style="width:6em;display:inline-block"></div>connection:&nbsp;{}
<a name="line5632"></a><div class="linenumber">5632</div><div style="width:4em;display:inline-block"></div>};
<a name="line5633"></a><div class="linenumber">5633</div>
<a name="line5634"></a><div class="linenumber">5634</div><div style="width:4em;display:inline-block"></div>logDebug("attempt&nbsp;to&nbsp;connect&nbsp;to&nbsp;WebRTC&nbsp;signalling&nbsp;server&nbsp;with&nbsp;application&nbsp;name="&nbsp;+&nbsp;applicationName);
<a name="line5635"></a><div class="linenumber">5635</div>
<a name="line5636"></a><div class="linenumber">5636</div><div style="width:4em;display:inline-block"></div>if&nbsp;(errorCallback&nbsp;===&nbsp;null)&nbsp;{
<a name="line5637"></a><div class="linenumber">5637</div><div style="width:6em;display:inline-block"></div>errorCallback&nbsp;=&nbsp;function(errorCode,&nbsp;errorText)&nbsp;{
<a name="line5638"></a><div class="linenumber">5638</div><div style="width:8em;display:inline-block"></div>self.showError(errorCode,&nbsp;errorText);
<a name="line5639"></a><div class="linenumber">5639</div><div style="width:6em;display:inline-block"></div>};
<a name="line5640"></a><div class="linenumber">5640</div><div style="width:4em;display:inline-block"></div>}
<a name="line5641"></a><div class="linenumber">5641</div>
<a name="line5642"></a><div class="linenumber">5642</div><div style="width:4em;display:inline-block"></div>connectToWSServer(successCallback,&nbsp;errorCallback);
<a name="line5643"></a><div class="linenumber">5643</div><div style="width:2em;display:inline-block"></div>};
<a name="line5644"></a><div class="linenumber">5644</div><div style="width:0em;display:inline-block"></div>};
<a name="line5645"></a><div class="linenumber">5645</div>
<a name="line5646"></a><div class="linenumber">5646</div><div style="width:0em;display:inline-block"></div>return&nbsp;new&nbsp;Easyrtc();
<a name="line5647"></a><div class="linenumber">5647</div>
<a name="line5648"></a><div class="linenumber">5648</div><div style="width:0em;display:inline-block"></div>}));&nbsp;
</code></pre>
</article>
</section>
</div>
		
	</div>
</div>
<footer class="template">
	<div class="wrapper-content">
		<p>Copyright &copy;2016 EasyRTC</p>
	</div>
</footer>
<!-- <script>prettyPrint();</script> -->
<!-- <script src="scripts/linenumber.js"></script> -->
</body>
</html>